Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

huangapple go评论75阅读模式
英文:

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

问题

Visual Studio Code今天开始弹出以下提示:

> 需要Java 11或更高版本才能运行。请下载并安装最新的JDK。

我需要使用JDK 8(正在使用Apache Beam,这是最后支持的版本)。我一直在使用它,直到出现这个问题。

我已经阅读了这篇文章并实施了其中提到的方法。

以下是我的Visual Studio Code的工作区设置(我已经双重检查了路径)

{
    "java.configuration.updateBuildConfiguration": "disabled",
    "java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
    "java.configuration.runtimes": [
        {
          "name": "JavaSE-1.8",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
          "default": true
        },
        {
          "name": "JavaSE-11",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",
        }
      ]
}

其他有用的信息:

➜ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

➜ which java
/usr/bin/java

尽管我已经成功在Visual Studio Code上运行JDK 8一段时间了,但今天开始出现这个问题。我不记得更新Visual Studio Code,所以不确定为什么现在显示这个提示,因为显然自从4月中旬以来就一直显示这个弹出窗口(在vscode-java Gitter频道上提出)。

英文:

Today Visual Studio Code started showing me a pop-up saying:

> Java 11 or more recent is required to run. Please download and install a recent JDK.

I need to use the JDK 8 (working on Apache Beam and that's the last supported version). I have been working on that and haven't had any issues until this came up.

I have read through this article and implemented the points mentioned there.

Here is my workspace settings on Visual Studio Code (I have double-checked the paths)

{
    "java.configuration.updateBuildConfiguration": "disabled",
    "java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
    "java.configuration.runtimes": [
        {
          "name": "JavaSE-1.8",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
          "default": true
        },
        {
          "name": "JavaSE-11",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",
        }
      ]
}

Other helpful information:

➜ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

and

➜ which java
/usr/bin/java

This started happening today even though I have been running JDK 8 on Visual Studio Code successfully for a while now. I don't remember updating Visual Studio Code, so I'm not sure as to why this is being displayed now since apparently the pop-up has been displayed since mid-April (asked on the vscode-java Gitter channel).

答案1

得分: 59

Change from

"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"

to

"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home"

and keep the rest of the settings as is.

英文:

Change from

"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"

to

"java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home"

and keep the rest of the settings as is.

答案2

得分: 20

For future readers. If you are using the extension "Spring Boot Tools" you may get a similar error to this. I had my JAVA_HOME set to java 8 but required java 11 to use the Spring Boot Tools Language Server. It seems that Spring Boot Tools uses whatever your JAVA_HOME environment variable is or in the PATH environment variable, Spring Project Issue. To override your JAVA_HOME variable you'll need to modify the spring-boot.ls.java.home setting.

  1. Open Visual Studio Code
  2. CRTL + , to open the settings
  3. Search spring-boot.ls.java.home
  4. Select 'Edit in settings.json'
  5. Your Java 11 installation → "spring-boot.ls.java.home": "C:\\Program Files\\Java\\jdk-11.0.10"
  6. Save and restart VS Code

Prereq: Have a Java 11 installation

英文:

For future readers. If you are using the extension "Spring Boot Tools" you may get a similar error to this. I had my JAVA_HOME set to java 8 but required java 11 to use the Spring Boot Tools Language Server. It seems that Spring Boot Tools uses whatever your JAVA_HOME environment variable is or in the PATH environment variable, Spring Project Issue. To override your JAVA_HOME variable you'll need to modify the spring-boot.ls.java.home setting.

  1. Open Visual Studio Code
  2. CRTL + , to open the settings
  3. Search spring-boot.ls.java.home
  4. Select 'Edit in settings.json'
  5. Your Java 11 installation → "spring-boot.ls.java.home": "C:\\Program Files\\Java\\jdk-11.0.10"
  6. Save and restart VS Code

Prereq: Have a Java 11 installation

答案3

得分: 17

以下是翻译好的部分:

不建议的解决方法(不具备未来性):

一个解决方法是将扩展程序“Language Support for Java(TM) by Red Hat”的版本从最新版本0.65.0降级回到vscode-java版本0.64.1

(除非您对JDK版本有限制,否则不建议这样做,只有在底部的备注中才有可能。如果可以的话,建议使用本主题的已接受答案)。*

摘自*需要运行Java 11或更高版本。请下载并安装最新的JDK“#1543*,这是如何安装早期扩展版本的方法(感谢在GitHub上发布此内容的用户):

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

请注意:

这只适用于那些无法安装JDK 11或更高版本的人:

  • 由于32位系统(同时被迫使用Oracle JDK 8作为他们的最后一个Oracle版本,因此不允许使用推荐的OpenJDK 14 - 请参见*JDK要求*→点击页面顶部的“Java开发工具包”链接→跳转至https://adoptopenjdk.net/)
  • 由于64位系统的限制:
    • 一个可能的原因是您不允许更新Gradle,并且您的Gradle版本低于4.7,请再次查看GitHub讨论
    • 一个“不太可能的”限制可能是一些高效的懒惰。您可能只是不想安装新的JDK并将Visual Studio Code设置回到旧的JDK,仅仅因为Java扩展的版本发生了变化:)。

如果没有重要的限制,您不应该这样做。最可能的限制是您使用的是Windows 32位,这仅适用于那些有一台旧笔记本电脑的人。

通常情况下:升级,然后您仍然可以根据*JDK要求*中的设置回到使用较旧的Java版本:

> 我需要将我的项目迁移到Java 11吗?
>
> "不,你不需要!嗯,你应该,但我们不是来判断的。仍然可以从Java 1.5到14编译/运行Java应用程序,前提是在用户的settings.json中配置了适当的java.configuration.runtimes。"

--> 这意味着您可以升级扩展程序,安装至少Java 11(JDK 11),并使用您选择的Java运行时版本<=您安装的Java版本。

有关Windows 64位的详细说明,请参见*“需要运行Java 11或更高版本。请下载并安装最新的JDK”#1543*。

英文:

One workaround is to downgrade the extension "Language Support for Java(TM) by Red Hat" from the most recent version 0.65.0. back to

vscode-java version 0.64.1.

(This is not recommended unless you have restrictions on the JDK version, it is just possible, see the remarks at the bottom. If you can, use the accepted answer of this thread instead.).

Taken from Java 11 or more recent is required to run. Please download and install a recent JDK" #1543, this is how to install the earlier extension version (thanks go to the GitHub user who posted this):

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

Please mind:

This should be relevant only for those who cannot install JDK 11 or higher:

  • Due to a 32-bit system (and who by the same time are forced to use an Oracle JDK 8 as their last Oracle version for 32 bit, so that they are not allowed to use the recommended OpenJDK 14 - see JDK Requirements &rarr; click at the top at the Java Development Kit link &rarr; jump to https://adoptopenjdk.net/)
  • Due to restrictions on a 64-bit system:
    • One plausible reason is that you are not allowed to update Gradle and you have a Gradle version below 4.7, see the github discussion again.
    • One "not that plausible" restriction could be some efficient laziness. You might simply not want to install a new JDK and change the Visual Studio Code settings back to your old JDK only because of a version change of the Java extension :).

You should not do this if you have no important restrictions. The most plausible restriction is that you use Windows 32 bit, which should be relevant only for those who have an old netbook lying around.

In the usual case: upgrade, and then you can still go back to using an older Java version by changing the settings according to JDK Requirements:

> Do I need to migrate my projects to Java 11?
>
> "NO, you don't! Well, you should, be we're not here to judge. It is
> still possible to compile/run Java applications from Java 1.5 to 14,
> provided the proper java.configuration.runtimes are configured in the
> user's settings.json."

--> This means you can upgrade the extension, install at least Java 11 (JDK 11), and use the Java runtime of your choice <= your installed Java version.

See detailed instructions for Windows 64bit at "Java 11 or more recent is required to run. Please download and install a recent JDK" #1543.

答案4

得分: 14

在Windows中,

  1. 下载并安装JDK 11。

  2. 安装完成后,在C:\Program Files\Java目录下会看到类似这样的文件夹:

  3. 打开VSC,进入设置(CTRL + , 或者底部左下角的管理图标 > 设置),然后搜索javahome

  4. 点击“在settings.json中编辑”,将C://Program Files//Java//jdk-11.0.8添加到java.home并保存文件。应该会看到如下内容:

{
"java.home": "C://Program Files//Java//jdk-11.0.8"
}

  1. 重启VS Code,你会看到如下内容:

安全警告!是否允许此工作区设置java.home变量? java.home: C://Program Files//Java//jdk-11.0.8

点击允许,然后你就可以开始使用了。

英文:

In Windows,

  1. Download and install JDK 11.

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

  1. Once the installation is complete, in C:\Program Files\Java you'll see something like this

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

As you can see, we have JDK 11 in C:/Program Files/Java/jdk-11.0.8.

  1. Open VSC and go to Settings (CTRL + , or Manage icon (bottom left) > Settings) and search for javahome

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

  1. Click in "Edit in settings.json", add C://Program Files//Java//jdk-11.0.8 to java.home and save the file. You should have something like this

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

{
    &quot;java.home&quot;: &quot;C://Program Files//Java//jdk-11.0.8&quot;
}
  1. Restart VS Code and you'll see something like this

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

> Security Warning! Do you allow this workspace to set the java.home
> variable? java.home: C://Program Files//Java//jdk-11.0.8

Click allow and you're good to go.


Note: If you get this error and are reliant on Java 8, fbricon mentions,

> you can still compile your projects with Java 8. JDK11 is only
> required to run vscode-java.

答案5

得分: 5

关于Java 11的要求:

Eclipse平台已决定将Java 11作为其2020年9月发布的最低要求。请查看*升级Eclipse SDK目标环境以适应九月的Eclipse发布...*。

由于vscode-java依赖于Eclipse JDT.LS服务器,因此对于vscode-java也有同样的要求。但时间表更为紧迫:事实上,vscode-java通常使用依赖于最新JDT功能的JDT.LS构建版本,因此实际上会发布Eclipse Platform/JDT的预发布版本。截至2020年7月22日,运行vscode-java现在需要Java 11。

这来自:https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements#java.configuration.runtimes

英文:

About the Java 11 requirement:

The Eclipse platform has decided to require Java 11 as the minimum requirement for its September 2020 release. See Upgrading the Eclipse SDK target environment for the September Eclipse release....

Because vscode-java depends on the Eclipse JDT.LS server, that same requirement to vscode-java. But the timeline is be more aggressive: Indeed, vscode-java usually consumes JDT.LS builds that depend on bleeding edge JDT features, so effectively shipping pre-release versions of Eclipse Platform/JDT. As of July 22nd, 2020, Java 11 is now required for running vscode-java.

This is from:https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements#java.configuration.runtimes

答案6

得分: 4

以下是翻译好的内容:

我曾经遇到了同样的问题,对于我的 setting.json 文件,以下更改解决了这个问题。非常感谢此评论在补丁说明中的帮助

"java.home": "C:/Program Files/AdoptOpenJDK/jdk-11.0.8.10-hotspot",
"java.configuration.runtimes": [
    {
        "name": "JavaSE-1.8",
        "path": "C:/Program Files/Java/jdk1.8.0_211",
        "default": true
    },
    {
        "name": "JavaSE-11",
        "path": "C:/Program Files/AdoptOpenJDK/jdk-11.0.8.10-hotspot",
    }
]
英文:

I was experiencing the same issue and the following change to my setting.json file resolved the issue. Big thanks to this comment on patch notes.

&quot;java.home&quot;: &quot;C:/Program Files/AdoptOpenJDK/jdk-11.0.8.10-hotspot&quot;,
&quot;java.configuration.runtimes&quot;: [
    {
        &quot;name&quot;: &quot;JavaSE-1.8&quot;,
        &quot;path&quot;: &quot;C:/Program Files/Java/jdk1.8.0_211&quot;,
        &quot;default&quot;: true
    },
    {
        &quot;name&quot;: &quot;JavaSE-11&quot;,
        &quot;path&quot;: &quot;C:/Program Files/AdoptOpenJDK/jdk-11.0.8.10-hotspot&quot;,
    }
]

答案7

得分: 2

  1. 只卸载所有之前的JDK,即小于或等于JDK 11。

  2. 从https://www.oracle.com/java/technologies/javase-jdk11-downloads.html重新安装JDK 11。

  3. 确保您的系统变量JAVA_HOME指向最新安装的JDK,例如"C:\Program Files\Java\jdk-11.0.8"(适用于Windows)。

  4. 重新启动Visual Studio Code。

  5. 转到工作区设置Java: Home

  6. 选择"在settings.json中编辑"。

  7. 您的settings.json应该如下所示:

    {
        "java.completion.favoriteStaticMembers": [
    
            "org.junit.Assert.*",
            "org.junit.Assume.*",
            "org.junit.jupiter.api.Assertions.*",
            "org.junit.jupiter.api.Assumptions.*",
            "org.junit.jupiter.api.DynamicContainer.*",
            "org.junit.jupiter.api.DynamicTest.*",
            "org.mockito.Mockito.*",
            "org.mockito.ArgumentMatchers.*",
            "org.mockito.Answers.*"
        ],
        "java.home": "C://Program Files//Java//jdk-11.0.8"
    }
    
英文:
  1. Just uninstall all previous JDKs, i.e., less than or equal to JDK 11.

  2. Re-install JDK 11 from https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

  3. Make sure your system variable JAVA_HOME points to the latest installed JDK like "C:\Program Files\Java\jdk-11.0.8" (for Windows)

  4. Restart Visual Studio Code

  5. Go to Workspace settings &rarr; Java: Home

  6. Select "Edit in settings.json"

  7. Your settings.json should look like:

    settings.json_image

    {
        &quot;java.completion.favoriteStaticMembers&quot;: [
    
            &quot;org.junit.Assert.*&quot;,
            &quot;org.junit.Assume.*&quot;,
            &quot;org.junit.jupiter.api.Assertions.*&quot;,
            &quot;org.junit.jupiter.api.Assumptions.*&quot;,
            &quot;org.junit.jupiter.api.DynamicContainer.*&quot;,
            &quot;org.junit.jupiter.api.DynamicTest.*&quot;,
            &quot;org.mockito.Mockito.*&quot;,
            &quot;org.mockito.ArgumentMatchers.*&quot;,
            &quot;org.mockito.Answers.*&quot;
        ],
        &quot;java.home&quot;: &quot;C://Program Files//Java//jdk-11.0.8&quot;
    }
    

答案8

得分: 1

以下是翻译好的部分:

对于不想安装Java 11并继续使用Java 8的用户,您需要安装之前版本的扩展“Language Support for Java(TM) by Red Hat redhat.java”。扩展的版本应为0.64.1,适用于Java 8。

请参考以下帖子中的回答:

https://stackoverflow.com/questions/63043585/visual-studio-code-showing-java-11-or-more-recent-is-required-to-run-please-do/63287737#63287737

英文:

For people who do not want to install Java&nbsp;11 and keep using Java&nbsp;8. You will have to install previous version of extension 'Language Support for Java(TM) by Red Hat
redhat.java". The extension version should be 0.64.1 for Java&nbsp;8.

Please refer the answer in the post below -

https://stackoverflow.com/questions/63043585/visual-studio-code-showing-java-11-or-more-recent-is-required-to-run-please-do/63287737#63287737

答案9

得分: 1

"将此变量添加到您的 settings.json 文件中。

"sonarlint.ls.javaHome": "/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home"
英文:

Add this variable in your settings.json file.

&quot;sonarlint.ls.javaHome&quot;: &quot;/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home&quot;

答案10

得分: 0

我一直在使用Adopt OpenJDK(Eclipse Temurin)来构建我的Gradle项目,并且在从Android Studio切换到VS Code时遇到了以下问题:“没有有效的JAVA_HOME设置来启动Gradle Language Server。请检查您的“java.home”设置。”

深入研究这个问题,我发现一些JDK安装程序甚至默认情况下都不会安装Java_Home

只需重新安装并选中相关选项,问题就会解决。
不要忘记重新启动VS Code。(至少我不需要编辑环境变量)

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"
Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

希望对您有帮助。

英文:

I have been using Adopt open JDK (Eclipse Temurin) for my Gradle builds and switching to VS Code from Android studio encountered with 'There is no valid JAVA_HOME setting to launch Gradle Language Server. Please check your "java.home" setting.'.

Delving into that issue I found some JDK Installers don't even install Java_Home by default.

Just reinstalling with fields checked, solved the issue.
Don't forget to restart VS Code. (no need to edit environment variables at least I didn't have to)

Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"
Visual Studio Code showing "Java 11 or more recent is required to run. Please download and install a recent JDK"

hope it helped.

答案11

得分: 0

在2022年三月,
我发现java.home已经更改为建议使用java.jdt.ls.java.home,然后只需更改它。
还有另一个设置,我进行了更改以消除该消息,请重新检查您计算机上的环境变量,是否设置为正确的Java 11或更高版本?
在进行这些设置后,重新启动VS Code,然后继续您的工作。

英文:

In 2022 March,

I found the java.home was changed to be recommended to use java.jdt.ls.java.home, then just change it.

And one another setting I did to get rid off that message, re-check the environment variables on your machine, does it set to proper Java 11 or above?

After made those settings, restart VS Code and then go on your work.

答案12

得分: 0

如果 Visual Studio Code 建议安装 OpenJDK17U-jdk_x64_windows_hotspot_xxxx,然后您应该选择本地文件夹,其中已经安装了 Eclipse Adoptium。例如,在我的电脑上是在 "C:\Program Files\Eclipse Adoptium\jdk-17.0.5.8-hotspot" 目录中,然后重新启动 Visual Studio Code。

英文:

If VisualSudioCode suggested to install OpenJDK17U-jdk_x64_windows_hotspot_xxxx, later You should select local folder where eEclipse Adptium was already installed.
for example in mine was in "C:\Program Files\Eclipse Adoptium\jdk-17.0.5.8-hotspot"
and re start VSC

huangapple
  • 本文由 发表于 2020年7月23日 05:38:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63043585.html
  • java
  • visual-studio-code

如何将MySQL表列作为变量放入 :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定