Changing the java.home path in VS code

22,861

Solution 1

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",

Solution 2

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'.

Share:
22,861
Ravikiran Talawar
Author by

Ravikiran Talawar

Updated on February 03, 2022

Comments

  • Ravikiran Talawar
    Ravikiran Talawar over 2 years

    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

    • nbokmans
      nbokmans almost 4 years
      Environment variables, more specifically the PATH variable.
    • Ravikiran Talawar
      Ravikiran Talawar almost 4 years
      @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\ming‌​w-w64\bin;e:\anconda‌​\Library\usr\bin;e:\‌​anconda\Library\bin;‌​e:\anconda\Scripts;C‌​:\Users\Lenovo\AppDa‌​ta\Local\Microsoft\W‌​indowsApps;C:\Users\‌​Lenovo\AppData\Local‌​\Programs\Microsoft VS Code\bin;C:\Users\Lenovo\AppData\Roaming\npm;F:\PyCharm Community Edition 2019.3.1\bin;
  • Farhad
    Farhad over 2 years
    it says it's deprecated, any update on the new way ?
  • TDiblik
    TDiblik about 2 years
    Hi, thanks for info, however I was unable to find a reason for this change. Could you please provide more info?