Caution: VS Code guides section is a work-in-progress, containing content contributed by students.
This guide will help you import and work with existing Java projects in VS Code.
Need help with following prerequisites? Check out our Preparing VS Code for Java guide first.
File
→ Open Folder...
After the project loads:
If you already have Java installed, VS Code should automatically detect and configure it when you create your project.
After creating your project, you may need to verify and configure VS Code to use the correct JDK version.
Ctrl+Shift+P
| Cmd+Shift+P
Java: Configure Java Runtime
and select itTo view and modify project settings:
Ctrl+Shift+P
| Cmd+Shift+P
Java: Open Project Settings
and select it.class
files will be stored.vscode/settings.json
You can also configure project settings by creating a .vscode/settings.json
file in the root directory:
{
"java.project.sourcePaths": [
"src"
],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
main
methodmain
method or at the top right corner of the editor, orF5
to run in debug modeAdd the following to your .gitignore
if not already present:
# Compiled class files
*.class
# VS Code workspace settings
.vscode/
Contributors: John Wong (@Johnwz123)