0

I'm about to finish my master thesis. The program, i developed, is a maven project with javaFx declared as dependencies

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>16-ea+4</version>
</dependency>

<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm-util</artifactId>
    <version>8.0.1</version>
</dependency>

 <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-base</artifactId>
    <version>16-ea+4</version>
</dependency>

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>16-ea+4</version>
</dependency>   

When I'm creating the jar using Maven-install the program runs on Oracle-JDK. But on openJDK it throws a java.lang.ClassNotFoundException.

My understanding is, that javaFX is not included in both JDKs anymore. Thats why I'm unsing maven and build the jar with all dependencies. That way it should find javaFx and start the program regardless the used JDK.

Assuming my assumption is correct that the error has something to do with javaFX.

To compile the Program I'm using JavaSE 13. It runs perfectly using Oracle JDK 15. But it throws a java.lang.ClassNotFoundException using openJDK 14 or 15.

---EDIT---

I'm not totaly sure if this error is regarded to JavaFX.

I'm starting the jar on the console with

java -jar "C:...\test.jar"

This works on the OracleJDK but not on the openJDK. Then the Console prinst:

Error: Could not find or load main class C:\...\test 
Caused by: java.lang.ClassNotFoundException: C:\...\test

I know how to print the stacktrace, using the IDE. But is it possible to print the stacktrace using the console in this case?

If so I will do it an edit this question to provide more info.

I would be so grateful for your help. I panic ^^

Schrello
  • 27
  • 5

3 Answers3

0

You are only providing us with some fragments of your setup. So it is difficult to give any specific advice. From what I see I'd say that your program cannot work on any Java which does not contain JavaFX because you do not provide the required arguments in your launch command. Have a look here for proven ways to launch JavaFX correctly: https://openjfx.io/openjfx-docs/

mipa
  • 10,369
  • 2
  • 16
  • 35
0

Do you have a MANIFEST.MF file? IT should point towards the class that has your public static void main(String[] args) method <-- Your main method.

Example:

MANIFEST.MF

Manifest-Version: 1.0
Main-Class: classes.TestClass

Helpful stackoverflow: Could not find or load main class with a Jar File

https://taylorial.com/cs1021/Jar.htm#jarwithjavafxpackagesincluded

JCompetence
  • 6,997
  • 3
  • 19
  • 26
0

my Prof just responded and says that it was just a typo in his commandline.

It works perfectly fine.

I will delete this question in view hours, cause it is not really a problem.

Thank you very much.

Schrello
  • 27
  • 5