- Download an official Java JDK 21:
- Such as one of the following trusted sources:
- Configure your download:
- Version: Select 21 - LTS (Long Term Support)
- Operating System: Select Windows
- Architecture: Select x64
- Click the Download button to get the
.msiinstaller
- Run the downloaded
.msiinstaller - During installation, MAKE SURE to check these options:
- ✅ "Add to PATH" - This allows VS Code to find Java
- ✅ "Set JAVA_HOME variable" - This sets the required environment variable
- Complete the installation by clicking through the remaining steps
- Open a new PowerShell window
- Run the following command:
java -version
- You should see output similar to:
openjdk version "21.0.x" 2024-xx-xx OpenJDK Runtime Environment Temurin-21.0.x+x (build 21.0.x+x) OpenJDK 64-Bit Server VM Temurin-21.0.x+x (build 21.0.x+x, mixed mode, sharing)- Check that Java is in your PATH:
Open PowerShell and run:Expected output:where.exe javaIf you see a path similar to the above, Java is correctly added to your system PATH.C:\Program Files\Eclipse Adoptium\jdk-21.x.x-hotspot\bin\java.exe
- Check that Java is in your PATH:
- Open VS Code
- Press
Ctrl+,to open Settings - Search for:
java.jdt.ls.java.home - Set the value to your Java 21 installation path:
(Replace
C:\\Program Files\\Eclipse Adoptium\\jdk-21.x.x-hotspotx.xwith your actual version numbers)
(The double backslashes\\are required to escape the single backslash\in Windows file paths when entering them in VS Code settings JSON.)
- Open VS Code
- Press
Ctrl+Shift+Pto open Command Palette - Type:
Java: Configure Java Runtime - See any error outputs
- Restart VS Code completely
- Try using the extension
- The extension should now work without errors
- Make sure you installed Java 21, not Java 11 or 17
- Verify with
java -versionthat Java 21 is active - Restart VS Code after installation
- Check that you selected "Add to PATH" during installation
- Manually add Java to your system PATH if needed
- Set the
java.jdt.ls.java.homesetting in VS Code as shown above
- ✅
Starting client failed: Launching server using command ... undefined\bin\java failed - ✅
Java runtime does not meet the minimum required version of '21' - ✅
Java is not installed or not found in PATH
Note: You can have multiple Java versions installed simultaneously. VS Code will use Java 21 for extensions that require it, while other projects can use different Java versions as needed.