I just installed java 11 coz VS code was prompting me to update it to java 11 or newer version. After installing java 14, I'm not getting how to change the path to new folder that has java 14.
In settings.json file the path can be seen when cursor hovered over java.home variable.

2 Answers
For those coming now, in VSCode settings change "java.home" to "java.jdt.ls.java.home"
From
"java.home": "C:\\Program Files\\Java\\jdk-17.0.2"
To
"java.jdt.ls.java.home": "C:\\Program Files\\Java\\jdk-17.0.2",
6 Comments
TDiblik
Hi, thanks for info, however I was unable to find a reason for this change. Could you please provide more info?
MouseNag
"settings.json file" : where can I find this file?
Arshad Yusuf
@MouseNag When you go to File -> Preferences -> Settings, there is an icon on the top right corner which says "Open Settings (JSON)" when you hover over it.
lilbiscuit
Reason:
"java.home" is deprecated.lonstar
What a PITA to find this setting. Thanks to Arshad for explaining the process.
|
The path to the Java Development Kit is searched in the following order:
- the java.home setting in VS Code settings (workspace then user settings)
- the JDK_HOME environment variable
- the JAVA_HOME environment variable
- on the current system path
The 'java.home' has the highest priority, and 'java.home' is different from the system environment variable. Open settings and search 'java.home', you can get the example:
"java.home":"C:\\Program Files\\Java\\jdk1.8.0_161"
It points to 'jdk' folder instead of 'jdkFolder\bin'.
4 Comments
Farhad
it says it's deprecated, any update on the new way ?
MouseNag
the java.home setting in VS Code settings (workspace then user settings) where can I find this file?
Ken Krueger
What if 1) I don't set java.home, 2) I don't set JDK_HOME, 3) I don't set JAVA_HOME 4) JDK 21 is on my system path 5) running a terminal with "java -version" shows JDK 21 6) VS code with Gradle says "invalid source release: 21". Also, IntelliJ and Eclipse have no issues with JDK 21.
lonstar
Note you need to open settings from the file-preference-settings menu and not the gear icon at bottom left. If you open through the gear icon you get some weird UI that doesn't show you the entire file and won't return lines matching java.home in your settings.json file.
PATHvariable.