visual-studio-code - 是否可以在 Visual Studio Code 中为 Java 项目选择 JDK 8?
问题描述
我正在尝试使用 Visual Studio Code 编译和运行基于 maven 的 Java 项目。
VSCODE 本身需要 JDK 11。我安装了 JDK 11 并将其添加为 VSCODE“Java:配置 Java 运行时”部分中的 java.home。
然而,该项目需要 Java 8。我有 JAVA_HOME 指向的 JDK 8,并且 pom.xml 指定
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
但是,当我编译并尝试在 VSCODE 中运行项目时,我会收到消息
Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
The compiler compliance specified is 1.8 but a JRE 11 is used.
即使 VSCODE 知道 JDK 8 是可访问的:
如何指示 VSCODE 使用 JDK 8(而不是 JDK 11)作为项目的运行时?
解决方案
是的,虽然 VSCode 支持 Java 1.5 及更高版本的项目,但它是可能的。您需要专注于运行时配置。检查下面的链接。 Java 运行时 VSCode
同时,我强烈建议您使用其他 IDE,如 eclipse 或 Intellij 来进行 Java 项目的正确调试、透视、maven、gradle、库支持等
推荐阅读
- .net - 如何使用 EntityFrameworkCore 5 执行包中的 oracle 11g SP
- flutter - 燃烧火柴的颤动动画
- ios - 在 CI 上的 UI 测试不稳定
- rust - actix web - sqlx - juniper:我得到'尝试使用同步解析器解析 Some("Query") 类型的异步字段用户'
- jquery - 如何在 laravel 中使用 ajax 上传文件?
- java - Android studio 如何从 CalendarView 获取 int 值(年、月、日)并使用它保存在 SQLite 中
- android - 无法在 mac OS 中启动 ADB
- docusignapi - DocuSign:“直播”,现在我收到 404 错误
- c++ - 如何读取 png 中的 IHDR 值?
- r - Spark Dataframe 到 R Dataframe 异常期间的 KryoSerializer 异常