[英]How to use Java 13 features in Eclipse?
Is there a way to get Eclipse to understand Java 13 features, such as text blocks ?有没有办法让 Eclipse 了解 Java 13 个功能,例如文本块? Eclipse reports errors for the following code:
Eclipse 报告以下代码错误:
class Main {
private String text = """
first line
second line
third line
""";
}
Errors include:错误包括:
first cannot be resolved to a type
Duplicate field Main.line
I suspect the problem is the combination of Eclipse and Java 13 in general.我怀疑问题通常是 Eclipse 和 Java 13 的组合。
Building with Maven succeeds (with appropriate --enable-preview
config).使用 Maven 构建成功(使用适当
--enable-preview
配置)。 The "installed JRE" in use is Java 13 (with --enable-preview
as default VM argument).正在使用的“已安装 JRE”是 Java 13(使用
--enable-preview
作为默认 VM 参数)。 Installing Java 13 Support for Eclipse 2019-09 doesn't seem to help either (doesn't add the Java 13 compliance level option).安装Java 13 支持 Eclipse 2019-09似乎也没有帮助(不添加 ZD52387880E1EA22817A72D375921389 合规级别选项)。
You would need to set JRE13 to eclipse and also will need to select BETA 13 under settings.您需要将 JRE13 设置为 eclipse 并且还需要在设置下设置 select BETA 13。
Check configuration steps at https://wiki.eclipse.org/Java13/Examples在https://wiki.eclipse.org/Java13/Examples检查配置步骤
In Project > Properies: Java Compiler make sure Java 13 preview features are enabled:在Project > Properies 中:Java Compiler确保 Java 13 个预览功能已启用:
I did follow the steps and it worked for me.我确实遵循了这些步骤,它对我有用。
Screenshots from MacOS
来自 MacOS 的屏幕截图
Perhaps because I am using Cucumber for Eclipse, in addition to the steps given by @www.hybriscx.com, I had to make jdk-13 my selected JRE.也许是因为我使用 Cucumber 为 Eclipse,除了@www.hybriscx.com 给出的步骤之外,我不得不制作我选择的 jdk-13。
Then I had to Edit that JDK-13 Installation to include the --enable-preview
argument.然后我必须编辑该 JDK-13 安装以包含
--enable-preview
参数。
I also set the Execution Environments page to set JavaSE-13 to use the jdk-13 JRE.我还将执行环境页面设置为将 JavaSE-13 设置为使用 jdk-13 JRE。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.