I’m using VSCode for my IDE for Java. I have the Setting.json file configured to output my .class files to a directory called ‘build’:
"java.project.outputPath": "build"
My Project Folder/File Layout is as follows:
math
src
Main.java
lib
Math.java
build <- This is where I want my .class files to be built keeping the same file structure as
in the src folder.
When I use
javac srcMain.java
The compiler writes the .class files in the .src directory, but I’m telling it to write the output in the .build directory. Any ideas what’s going on?
2
Answers
I fixed the problem. I was using the Command Line. VSCode only builds to the specified build path if the build command is run through the gui.
I didn’t see
settings.json
in the workspace directory structure you provided. I think this may be the cause of the problem.This setting only takes effect in the workspace scope.
You can create a folder named .vscode in your workspace, then create
settings.json
:Add the codes in workspace settings.json:
"java.project.outputPath": "build"
.