简体   繁体   English

使用Java 10运行.jar文件时缺少JavaFX应用程序类

[英]Missing JavaFX application class when running .jar file with Java 10

My problem is the following: I cannot run .jar files built with java 1.8 after I installed Java 10. 我的问题如下:安装Java 10后,无法运行用Java 1.8生成的.jar文件。

In console, java -version shows: 在控制台中,java -version显示:

java version "10.0.2" 2018-07-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode) java版本“ 10.0.2” 2018-07-17 Java(TM)SE运行时环境18.3(内部版本10.0.2 + 13)Java HotSpot(TM)64位服务器VM 18.3(内部版本10.0.2 + 13,混合模式)

When I double click the .jar, it does not start, and when I run it from console with java -jar APP.jar, then I get following error: Missing JavaFX application class feedmeclient.FeedMeClient 当我双击.jar时,它没有启动,并且当我使用java -jar APP.jar从控制台运行它时,出现以下错误: 缺少JavaFX应用程序类feedmeclient.FeedMeClient

Interesting thing is that IT WORKS if I revert to Java 1.8 or if I call java 1.8 with full path in console like this: "C:\\Program Files (x86)\\Java\\jre8u162\\bin\\java.exe" -jar APP.jar, then it works with no problem. 有趣的是, 它的作品 ,如果我恢复到Java 1.8,或者如果我喜欢这个控制台调用java 1.8完整路径: “C:\\ Program Files文件(x86)的\\的Java \\ jre8u162 \\ BIN \\的java.exe” -jar APP。 jar,则可以正常工作。

APP.jar was built with NetBeans 8.2 Shouldn't Java be backward compatible? APP.jar是使用NetBeans 8.2构建的,Java不应该向后兼容吗?

The .jar file contains the MANIFEST and it looks like this: .jar文件包含清单,看起来像这样:

Manifest-Version: 1.0
Implementation-Title: FeedMeClient
X-COMMENT: Main-Class will be added automatically by build
Implementation-Version: 1.0
Permissions: sandbox
Codebase: *
JavaFX-Version: 8.0
Class-Path: lib/CustomFXComponents.jar lib/FeedMeDataLayer.jar lib/com
 mons-io-2.4.jar
Created-By: JavaFX Packager
Implementation-Vendor: bostinac
Main-Class: feedmeclient.FeedMeClient

So...after a lot of struggle I think I found the problem ... actually there were more problems: 所以...经过很多努力,我认为我发现了问题...实际上还有更多问题:

  1. It seems that Netbeans 8.2 does not work with Java 9 or 10. I took NetBeans 9 from netbeans.apache.org as Ralf Renz suggested, and I was able to load the project into it, and compile it with JDK 10. Surprise surprise, when I ran it inside NetBeans I get the same Missing JavaFX application class feedmeclient.FeedMeClient error :) 看来Netbeans 8.2不能与Java 9或10一起使用。我按照Ralf Renz的建议从netbeans.apache.org中获取了NetBeans 9,并且能够将项目加载到其中,并使用JDK 10进行编译。当我在NetBeans中运行它时,我得到了相同的缺少JavaFX应用程序类feedmeclient.FeedMeClient错误:)

    Also the IDE was struggling to scan the classes and to bring up the pop up where you select your main class of the project to be used. 此外,IDE还在努力扫描类并在您选择要使用的项目的主类的位置弹出弹出窗口。 The dialog window will get stuck and no class was found....hmmm strange enough. 对话框窗口将被卡住,找不到任何类。 The project did not had any error, it compiled and build just fine. 该项目没有任何错误,它进行了编译和构建。 Then I started to investigate libraries used. 然后,我开始研究使用的库。 I use one library which I build also with Java 8, and this library called DataLayer.jar, was accessing files using JAXB to write and read XML files. 我使用了一个我也用Java 8构建的库,这个名为DataLayer.jar的库正在使用JAXB访问文件来写入和读取XML文件。

  2. Now the main problem: The JAXB used to be inside Java distribution untill now, but in Java 10 they removed it :((( Funny thing is that the IDE would not complain because the DataLayer.jar used as library was already compiled, and I guess it already contained needed classes. But somehow, something was still missing, because when I would ran DataLayer.jar individually, then it would crash because some JAXB symbols could not be resolved. At runtime that confusing " Missing JavaFX application class feedmeclient.FeedMeClient " was thrown even if it had nothing to do with the real reason of the problem. 现在的主要问题是:JAXB以前一直在Java发行版内部,但是在Java 10中,他们删除了它:((可笑的是IDE不会抱怨,因为用作库的DataLayer.jar已经被编译了,我猜测它已经包含了所需的类,但不知何故,有什么东西在人仍下落不明,因为当我将单独跑DataLayer.jar,那么它就会崩溃,因为一些JAXB符号无法得到解决。在运行时,它混淆“ 缺少JavaFX应用程序类feedmeclient.FeedMeClient即使与问题的真正原因无关也被抛出。

Good thing is that you can get JAXB as library and use it in project. 好消息是,您可以将JAXB作为库并在项目中使用。 After I did this, everything went back to normal. 完成此操作后,一切恢复正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在命令提示符下运行 jar 文件时显示错误“缺少 JavaFX 运行时组件,并且需要运行此应用程序” - Showing error " JavaFX runtime components are missing, and are required to run this application" while running jar file in command prompt 运行Java jar应用程序时如何在系统任务栏中重新运行用javafx编写的用户界面 - How to re-run the user interface written with javafx in system tray when java jar application is running Java 运行 jar 文件时找不到或加载主 class - Java Could not find or load main class when running jar file 缺少 JavaFX 应用程序类 - Missing JavaFX application class 使用 JavaFx 运行 Java Jar 文件时如何解决“图形设备初始化失败:d3d,sw” - How to solve "Graphics Device initialization failed for : d3d, sw" when running a java Jar file with JavaFx 我在 jar 文件中的 javaFX 应用程序显示错误“JavaFX 运行时组件丢失,需要运行此应用程序” - My javaFX application in jar file show error “JavaFX runtime components are missing, and are required to run this application” 测试应用程序是否在Java的jar文件中运行 - Test if application is running in a jar file in Java 在编译Java类并从命令控制台运行Java文件时,如何包含Java jar文件? - How will I include a Java jar file when compiling a Java class and running the Java file from the command console? "在使用 Maven 构建的 Swing 应用程序中运行 JavaFx 时缺少 SwingInterOpUtils" - Missing SwingInterOpUtils when running JavaFx in an Swing application build with Maven 在另一个 Java 应用程序的面板中运行 Java 应用程序(JAR 文件) - Running a Java application (JAR file) in a panel of another Java application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM