1

I try to compress my javafx app into jar, and when i run:

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

it raise this error:

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)

I'm sure jfxrt.jar include 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

why it will raise "ClassNotFoundException"?

update

my java version is:

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)
4
  • You shouldn't need to specify that jar file on the classpath: jar files in the lib/ext folder are on the class path by default. Are you certain that java is pointing to that jdk version (what does java -version give?). Commented Jul 31, 2016 at 3:44
  • @James_D even i remove -cp, the error still be raised, I hope a way to fix it Commented Jul 31, 2016 at 3:51
  • Which JDK version are you running with? Commented Jul 31, 2016 at 3:51
  • @James_D, thx, I find the reason, since i use openjdk not oracle jdk, when switch to oracle jdk, everything work Commented Jul 31, 2016 at 3:54

2 Answers 2

2

I find the reason: since my java version is:

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)

i should use oracle bin/java instead, in my case, I use following will work:

/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
Sign up to request clarification or add additional context in comments.

Comments

0

The problem is probably de java version in your IDE is not the same that the java version of your linux when you "java" comamnd.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.