VSCode 未绑定的类路径容器 JRE 系统库 [JavaSE-15]

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

VSCode Unbound classpath container JRE System Library [JavaSE-15]

问题

我一直在使用JDK14和VSCode进行Java项目的编程。最近JDK15已经发布,我切换到了这个JDK版本。关于配置方面,我将VSCode的java.home和系统的JAVA_HOME都指向了新的JDK文件夹。

当我清除了VSCode的缓存并重新启动IDE后,我开始收到以下错误:

{
	"resource": "/E:/dev/java/challenges/",
	"owner": "_generated_diagnostic_collection_name_#3",
	"code": "963",
	"severity": 8,
	"message": "Unbound classpath container: 'JRE System Library [JavaSE-15]' in project 'challenges'",
	"source": "Java",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 1
}

我已经看过类似的问题和答案,但是没有一个是针对VSCode的。

VSCode 未绑定的类路径容器 JRE 系统库 [JavaSE-15]

英文:

I have been programming a java project using JDK14 and VSCode. Recently JDK15 is available, and I switched to the JDK. As for configuration, I pointed the VScode java.home and system JAVA_HOME to the new JDK folder.

When I clear the VSCode cache and restart the IDE, I started receiving this error

{
"resource": "/E:/dev/java/challenges/",
"owner": "_generated_diagnostic_collection_name_#3",
"code": "963",
"severity": 8,
"message": "Unbound classpath container: 'JRE System Library [JavaSE-15]' in project 'challenges'",
"source": "Java",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1
} 

I have seen similar questions/answers, but none of them was directed to VSCode.

VSCode 未绑定的类路径容器 JRE 系统库 [JavaSE-15]

答案1

得分: 3

这个帮助很有用;

替换为:
在POM中构建块为

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
英文:

https://stackoverflow.com/a/42525941/1005462
this one was helpfull;

replace :
build block in POM to

&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;configuration&gt;
                &lt;source&gt;1.8&lt;/source&gt;
                &lt;target&gt;1.8&lt;/target&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;

答案2

得分: 2

根据 Twitter 上的 VsCode-Java,JDK15 的支持预计要在九月底之前才会发布,这里有一个与 Java 15 不支持相关的 GitHub 问题

英文:

According to VsCode-Java in Twitter, JDK15 support won't be released until the end of September, and here is a github issue that's related to Java 15 not support.

答案3

得分: 1

我在VSCode中构建Java应用程序还很新。在我的情况下,我正在使用Spring Boot开发微服务。以下是我解决该问题所做的步骤:

  1. 确保 JAVA_HOME 环境变量注册到正确的路径。
  2. .vscode 目录下的 settings.json 中配置 java.jdt.ls.java.home 为 JDK 路径。以下是我的配置示例。
{
    "java.configuration.updateBuildConfiguration": "automatic",
    "java.compile.nullAnalysis.mode": "automatic",
    "java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home"
}
  1. 重新启动 VSCode。
英文:

I am new to building Java apps in VSCode. In my case, I was developing a microservice using Spring Boot. Here is what I've done to solve the issue ;

  1. Make sure JAVA_HOME env variable is registered to the right path
  2. Configured JDK path in java.jdt.ls.java.home to settings.json located inside .vscode. Here is my configuration.
    <pre>
    {
    "java.configuration.updateBuildConfiguration": "automatic",
    "java.compile.nullAnalysis.mode": "automatic",
    "java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home"
    }
    </pre>
  3. Restart the VSCode

huangapple
  • 本文由 发表于 2020年9月18日 06:25:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63946894.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定