skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. 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".

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search