gpt4 book ai didi

java.lang.ClassNotFoundException : javafx. 应用程序.Application

转载 作者:行者123 更新时间:2023-11-30 02:50:56 24 4
gpt4 key购买 nike

我尝试将我的 javafx 应用程序压缩到 jar 中,当我运行时:

java -jar /home/roroco/Dropbox/rbs/ro_cmds_global/j/fileToClip/build/libs/server-1.0.jar -cp /home/roroco/Downloads/jdk1.8.0_74/jre/lib/ext/jfxrt.jar

它引发此错误:

Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

我确定 jfxrt.jar 包含 javafx.application.Application

roroco@roroco /tmp/fileToClip $ jar tf 
/home/roroco/Downloads/jdk1.8.0_74/jre/lib/ext/jfxrt.jar|gr Application\.class
com/sun/glass/ui/Application.class
com/sun/glass/ui/gtk/GtkApplication.class
javafx/application/Application.class

为什么会引发“ClassNotFoundException”?

更新

我的java版本是:

roroco@roroco ~/Dropbox/try/j/try $ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

最佳答案

我找到原因了:因为我的java版本是:

roroco@roroco ~/Dropbox/try/j/try $ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

我应该使用 oracle bin/java 代替,就我而言,我使用以下方法可以工作:

/home/roroco/Downloads/jdk1.8.0_74/bin/java -jar /home/roroco/Dropbox/rbs/ro_cmds_global/j/fileToClip/build/libs/server-1.0.jar

关于java.lang.ClassNotFoundException : javafx. 应用程序.Application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38680491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com