简体   繁体   English

我无法在 Visual Studio Code 上设置 JDK

[英]I can't set up JDK on Visual Studio Code

I saw this:我看到了这个:

找不到 Java 运行时

clicked on it, it redirected me to Red Hat site and made me download Red Hat Developer Studio, but as I said I want it in Visual Studio Code.单击它,它会将我重定向到 Red Hat 站点并让我下载 Red Hat Developer Studio,但正如我所说,我希望它在 Visual Studio Code 中。 I did download JDK, but don't know what to do next.我确实下载了JDK,但不知道下一步该怎么做。

  • Press Ctrl + comma .Ctrl +逗号
  • Search for "java.home" .搜索“java.home”

In case you are on the newest vscode version:如果您使用的是最新的 vscode 版本:

  • Type in your java path( Don't forget to put the path in " " ).*输入你的java路径(不要忘记把路径放在" " )。*

In case you are on an older version of vscode:如果您使用的是旧版本的 vscode:

  • Click on the pencil next to the line starting with "java.home" .单击以"java.home"开头的行旁边的铅笔。
  • click on "Copy to settings" .点击“复制到设置”
  • Type in your java path( Don't forget to put the path in " " ).*输入你的java路径(不要忘记把路径放在" " )。*
  • Press Ctrl + S .Ctrl + S

*If you don't know your java path, type in which java in your terminal(On windows, Please note the right format, eg: "java.home": "C:/Program Files/Java/jdk-11.0.2" ) *如果你不知道你的java路径,在你的终端中输入which java (在windows上,请注意正确的格式,例如: "java.home": "C:/Program Files/Java/jdk-11.0.2" )

这对我不起作用,vsc 警告说“此设置将被弃用,请使用 te JAVA HOME”但我已配置

Shifting to java 11 did the trick for me.转移到 Java 11 对我有用。 if you have settings.json then如果你有 settings.json 那么

"java.home": "/usr/lib/jvm/java-11-openjdk-amd64

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

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