This is a WIP community resource, containing content contributed by community members.
This guide will help you import and work with existing Java projects in VS Code.
Ensure you have followed our guide on Preparing VS Code for Java.
File
→ Open Folder...
After the project loads:
If Java features like syntax highlighting or IntelliSense are not working, ensure the Java Extension Pack is installed and VS Code has fully initialized.
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 itIf no JDK options appear, try reloading VS Code (Open the Command Palette: / Ctrl+Shift+P
| Cmd+Shift+P
, then type and select Developer: Reload Window
) and ensure your JDK is properly installed and added to your system’s PATH
or select "Find a local JDK" to locate the installed JDK in your file system.
To 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, if it does not exist:
In the project root directory, create a folder named .vscode
.
Inside the .vscode
folder, create a file named settings.json
. This file will store the project's VS Code configuration settings.
Add these configuration settings to the settings.json
file. Update the values to match your project's source folders, output directory, and library paths as needed.
{
"java.project.sourcePaths": [
"src"
],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
main
methodmain
method or in the top right corner of the editorIf the ‘Run’ button does not appear, try reloading VS Code (Open the Command Palette: / Ctrl+Shift+P
| Cmd+Shift+P
, then type and select Developer: Reload Window
) or right-click inside the main
method of your Java file and select ‘Run Java’ from the context menu.
Add the following to your .gitignore
if not already present:
# Compiled class files
*.class
# VS Code workspace settings
.vscode/
Contributors: John Wong (@Johnwz123)