简体   繁体   English

在 VS 代码中更改 java.home 路径

[英]Changing the java.home path in VS code

I just installed java 11 coz VS code was prompting me to update it to java 11 or newer version.我刚刚安装了 java 11 因为 VS 代码提示我将其更新到 java 11 或更新版本。 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. 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. 附上图片 附图片 1

The path to the Java Development Kit is searched in thefollowing order : Java 开发套件的路径按以下顺序搜索:

  1. the java.home setting in VS Code settings (workspace then user settings) VS Code 设置中的 java.home 设置(工作区然后用户设置)
  2. the JDK_HOME environment variable JDK_HOME 环境变量
  3. the JAVA_HOME environment variable JAVA_HOME 环境变量
  4. on the current system path在当前系统路径上

The 'java.home' has the highest priority, and 'java.home' is different from the system environment variable. 'java.home' 具有最高优先级,'java.home' 与系统环境变量不同。 Open settings and search 'java.home', you can get the example:打开设置并搜索'java.home',可以得到示例:

"java.home":"C:\\Program Files\\Java\\jdk1.8.0_161"

It points to 'jdk' folder instead of 'jdkFolder\bin'.它指向“jdk”文件夹而不是“jdkFolder\bin”。

For those coming now, in VSCode settings change "java.home" to "java.jdt.ls.java.home"对于那些即将到来的人,在 VSCode 设置中将“java.home”更改为“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",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM