Home > database >  Java/VScode- .Class Files Not Being Sent to Output Directory
Java/VScode- .Class Files Not Being Sent to Output Directory

Time:01-20

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 src\Main.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?

CodePudding user response:

I didn't see settings.json in the workspace directory structure you provided. I think this may be the cause of the problem.

"java.project.outputPath"

This setting only takes effect in the workspace scope.

You can create a folder named .vscode in your workspace, then create settings.json:

enter image description here

Add the codes in workspace settings.json: "java.project.outputPath": "build".

CodePudding user response:

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.

  • Related