文件已被更新版本的Java Runtime编译,出现SceneBuilder错误。

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

File has been compiled by a more recent version of the Java Runtime error SceneBuilder

问题

我已使用JLink + JPackage将JavaFX应用程序构建为自包含应用程序。我正在使用JDK 14。然而,当我尝试在IntelliJ的Scenebuilder中打开我的某个FXML文件时,我会收到以下错误:

“文件已由更新版本的Java Runtime(类文件版本58.0)编译,此版本的Java Runtime仅识别高达55.0的类文件版本。”

要在开发环境中运行应用程序,我使用mvn clean javafx:run命令。

当我检查IDE的编译器设置时,JDK正确设置为14,JAVA_HOME变量也是如此,如下所示。我该如何解决这个问题?

PS C:\dev> java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
英文:

I've used JLink + JPackage to build a JavaFX app into a self-contained application. I'm using JDK 14. However, when I try to open one of my FXML files in IntelliJ's Scenebuilder I get this error:

File has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0.

To run the app in development environment, I use mvn clean javafx:run.

When I check in the IDE's compiler settings, the JDK is correctly set to 14, and so is the JAVA_HOME variable, as shown below. How do I fix this?

PS C:\dev> java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

答案1

得分: 2

我会说问题出在您的自定义组件上。您可能使用Java 14编译了它们,并将生成的jar文件放入了SceneBuilder中。因此,每次加载使用这些组件之一的FXML文件时,都会收到该错误消息,因为您组件的类文件版本较低于SceneBuilder本身的版本。出于兼容性的考虑,建议您始终使用目标11编译您的组件。您可以使用Java 14编译器来实现这一点。这将增加一般的兼容性,并解决您目前遇到的问题。

英文:

I'd say the problem are your custom components. You have probably compiled them with Java 14 and put the resulting jars into SceneBuilder. So each time when you load an FXML file which uses one of these components you will get that error message because the class file version of your components is younger than the version of SceneBuilder itself. For compatibility reasons it would be a good idea to compile your components with a target 11 anyway. You can do that with your Java 14 compiler. This would increase compatibility in general and solve your problem at hand.

答案2

得分: 1

我认为(我不是百分之百确定,但这是有道理的)对于这个问题有两个答案:

  1. 你的IntelliJ正在使用旧版本的Java(范围可以是6到13)。因此,你需要允许IntelliJ使用更新的Java版本(JDK14)。
  2. 使用旧版本的Java构建你的应用程序,当然,由于Java的旧版本,你可能需要更改一些函数。
英文:

I think (I'm not 100% sure but it makes sense) there are 2 answer's to this...

  1. Your intellij is using an older version of java (It can range from 6 to 13). So you would need to allow intellij to use a newer version of java (JDK14).
  2. Build your application with older version of java, of course you might need to change some functions because of older version of java.

huangapple
  • 本文由 发表于 2020年8月28日 21:35:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63634840.html
匿名

发表评论

匿名网友

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

确定