Skip to content
Advertisement

Visual Studio Code puts .class files in src folder when compiling

When I compile and run my project, Visual Studio Code automatically generates a .class file for each .java file and puts them in the src folder, but they are already stored in the bin folder. Why are they duplicated?

screenshot

Advertisement

Answer

If you compile .java file manually by command javac name.java, the .class file will be generated in folder src. By default, it’s stored in folder bin with default setting

"java.project.outputPath": "bin"

Turn to .vscode/settings.json, check if you’ve set src as the value of java.project.outputPath. Change it back to bin then cleaning java language server workspace from Command Palette.

Advertisement