13

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. Image attached image attached 1

2
  • 1
    Environment variables, more specifically the PATH variable. Commented Jul 23, 2020 at 15:01
  • @nbokmans yes I've changed it there, Here's output from cmd C:\Users\Lenovo>echo %PATH% ...C:\Program Files\Java\jdk-14.0.2\bin;e:\anconda;e:\anconda\Library\mingw-w64\bin;e:\anconda\Library\usr\bin;e:\anconda\Library\bin;e:\anconda\Scripts;C:\Users\Lenovo\AppData\Local\Microsoft\WindowsApps;C:\Users\Lenovo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Lenovo\AppData\Roaming\npm;F:\PyCharm Community Edition 2019.3.1\bin; Commented Jul 23, 2020 at 15:14

2 Answers 2

38

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",
Sign up to request clarification or add additional context in comments.

6 Comments

Hi, thanks for info, however I was unable to find a reason for this change. Could you please provide more info?
"settings.json file" : where can I find this file?
@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.
Reason: "java.home" is deprecated.
What a PITA to find this setting. Thanks to Arshad for explaining the process.
|
9

The path to the Java Development Kit is searched in the following order:

  1. the java.home setting in VS Code settings (workspace then user settings)
  2. the JDK_HOME environment variable
  3. the JAVA_HOME environment variable
  4. 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

it says it's deprecated, any update on the new way ?
the java.home setting in VS Code settings (workspace then user settings) where can I find this file?
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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.