JavaFX SDK, I am stuck, not even java -jar ....

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
papaworx
Level 3
Level 3
Posts: 109
Joined: Tue Sep 03, 2013 9:43 am
Location: Canada

JavaFX SDK, I am stuck, not even java -jar ....

Post by papaworx »

For the past 10 odd years I have designed, distributed and supported a free java 1.8 application for a group of colleagues. I used many editions of Eclipse with E(fx)clipse over the years. Because of my age, I am converting the project to 'Open Source' on GitHub'. That's when my computer crashed, and I had to reinstall the OS and the various tools. I ran into problems associated with the licensing changes of Oracle Java. Not only can't I compile updates, I can't even run .jars that ran without problems, and still work on some other computers, I have access.
Attached is a summary of my present installation:

---------------------------------------
ralph@Dad:~$ ls ~/Java_Lib -all
total 20
drwxrwxr-x 5 ralph ralph 4096 Jun 30 17:35 .
drwxr-xr-x 37 ralph ralph 4096 Jun 30 17:16 ..
drwxr-xr-x 2 ralph ralph 4096 Apr 19 17:47 javafx-jmods-18.0.1
drwxrwxr-x 4 ralph ralph 4096 Apr 19 13:47 javafx-sdk-18.0.1
drwxrwxr-x 8 ralph ralph 4096 Jun 30 17:16 jdk-18.0.1.1


ralph@Dad:~$ echo $PATH
/home/ralph/Java_Lib/jdk-18.0.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin

ralph@Dad:~$ echo $JAVA_HOME
/home/ralph/Java_Lib/jdk-18.0.1.1

ralph@Dad:~$ echo $PATH_TO_FX
/home/ralph/Java_Lib/javafx-sdk-18.0.1

ralph@Dad:~/Documents/Computer/G_String/G_String_L/jars$ java -jar GS_L.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:59)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 13 more
-------------------------------------------------------- any advice and help is appreciated
Last edited by LockBot on Sun Jan 01, 2023 11:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
spamegg
Level 14
Level 14
Posts: 5096
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: JavaFX SDK, I am stuck, not even java -jar ....

Post by spamegg »

What does java -version say?

It's generally not a good idea to manually install Java versions like that, I recommend using SDKMAN https://sdkman.io/

Java 18 is a bit too new and some older software does not work properly with it. I'd suggest first trying the Java 11 version (that Mint comes installed with). If that doesn't work, maybe try Java 8. It's available in the repositories.
papaworx
Level 3
Level 3
Posts: 109
Joined: Tue Sep 03, 2013 9:43 am
Location: Canada

Re: JavaFX SDK, I am stuck, not even java -jar ....

Post by papaworx »

So I wiped out the the 20.3 installation and loaded a virginal one (with java 11 default), I downloaded and installed openjfx11, set the paths and tried to run my legacy jar (1.8).

Nothing happened by clicking on the run-permitted jar. So I ran it in terminal mode java -jar .... It complained: Caused by: java.lang.ClassNotFoundException: javafx.application.Application. I went to look in the jfx lib, and true, there was no 'Application.jar' in /usr/share/openjfx/lib.

I wonder if the problem is due to the fact that the application was built with version 1.8, but it was supposed to run under 11. But javafx for version 8 is no longer available. What else can I do?
User avatar
spamegg
Level 14
Level 14
Posts: 5096
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: JavaFX SDK, I am stuck, not even java -jar ....

Post by spamegg »

If you have your source code, try recompiling and creating the jar for a newer version of Java that has FX available. That's all I can think of.
dave0808
Level 5
Level 5
Posts: 987
Joined: Sat May 16, 2015 1:02 pm

Re: JavaFX SDK, I am stuck, not even java -jar ....

Post by dave0808 »

papaworx wrote: Fri Jul 01, 2022 6:35 pm Nothing happened by clicking on the run-permitted jar. So I ran it in terminal mode java -jar .... It complained: Caused by: java.lang.ClassNotFoundException: javafx.application.Application. I went to look in the jfx lib, and true, there was no 'Application.jar' in /usr/share/openjfx/lib.
First off, there won't be any Application.jar in any directory. The string javafx.application.Application refers to a class name which lives inside the file /usr/share/java/javafx-graphics-11.jar.
papaworx wrote: Fri Jul 01, 2022 6:35 pm I wonder if the problem is due to the fact that the application was built with version 1.8, but it was supposed to run under 11. But javafx for version 8 is no longer available. What else can I do?
Yes, that's the cause of your issues. With Java 8, JavaFX was included and it was simple to compile a program and run it. With Java 11, you have to either recompile and include the JavaFX module, or you can run with Java 11 and include the module at runtime.

Note that Java does not make use of the PATH environment variable for picking up modules or additional JARs.

So you will need to do something like the following...

Code: Select all

java --module-path  /usr/share/openjfx/lib --add-modules=javafx.controls -jar papaworx-application.jar
I *think* you might need to use javafx.fxml instead of javafx.controls, if you are using FXML. I don't.
Locked

Return to “Software & Applications”