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

MacOS和Windows 10都说一下

首先下载jdk 11

下载地址

https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

需要账号登录,在这里找一个

http://bugmenot.com/view/oracle.com

MacOS下载这个

Windows 10下载这个

MacOS

1、打开.dmg文件,一路安装到底

2、打开环境变量配置文件bash_profile

vim ~/.bash_profile 
# The JAVA_PATH_HOME
JAVA_8_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"
JAVA_11_HOME="/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home"

JAVA_HOME=$JAVA_8_HOME

CLASS_HOME="$JAVA_HOME/lib"
PATH=".;$PATH:$JAVA_HOME/bin"
export JAVA_HOME
export CLASS_PATH
export PATH

其实这里配不配置也不影响VS Code。

3、打开VS Code

Code -> Preferences -> Settings,搜索java home

解决Java 11 or more recent is required to run.Please download and install a recent JDK_第1张图片

点击Edit in settings.json,添加这一行(如果是json文件的最后一行,结尾不要加",")

{
    ...
    "java.home": "/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home",
    ...
}

Mac的JDK都是安装到一个指定目录的:/Library/Java/JavaVirtualMachines/

4、重启VS Code

 

Windows 10

1、安装jdk11

2、打开VS Code

File -> Preferences -> Settings,搜索java home

然后添加这一行(如果是json文件的最后一行,结尾不要加",")

"java.home": "C://Program Files//Java//jdk-11.0.8"
{
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "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"
}

3、重启VS Code

你可能感兴趣的:(VS,Code)