Closed c-wenlong closed 8 months ago
Sorry, Im not exactly sure how the discussion here answers my concern about the error.
The reason is that the Java 11 runtime will check if the main class extends javafx.application.Application, and if that is the case, it strongly requires the javafx platform to be available as a module, and not as a jar for example.
What I gather from this is that the JavaFX module has to be present within the user's computer and that the main class has to extend Application, which were steps I took. Maybe you can help me draw the link here? Appreciate the help!
looks somewhat similar to my question #369 (the provided comment just say "some classpath issue" with no explanation)
It was discussed here: http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-June/021977.html
Quote from the java.net link:
This error comes from sun.launcher.LauncherHelper in the java.base module. The reason for this is that the Main app extends Application and has a main method. If that is the case, the LauncherHelper will check for the javafx.graphics module to be present as a named module:
Optional
om = ModuleLayer.boot().findModule(JAVAFX_GRAPHICS_MODULE_NAME); If that module is not present, the launch is aborted. Hence, having the JavaFX libraries as jars on the classpath is not allowed in this case.
In other words, it's the behaviour of sun.launcher.LauncherHelper itself. If you're interested you can read the source code here: https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.base/share/classes/sun/launcher/LauncherHelper.java
Got it, I will just take it as a classpath specification that requires Launcher.java to be in the same directory as the other packages. Thanks!
Problem
As I am a Mac user with M1 core, my
.jar
file runs fine on my friend's MacBook (M1) but not my other friends MacBook (Intel), and it doesn't run on 4/4 of my friends' Windows (Intel).How I fixed it.
Following #241 , I moved my
Launcher.java
fromsrc/java/kbot/gui
tosrc/java/kbot
as shown below after the change. Furthermore, I renamed my original file containing thestart()
method for the Application fromKBot.java
toMain.java
.Question
So, at this moment, since I made the changes in a single commit, I do not understand what exactly made my jar file work. And I am seeking to clarify why my original program works for M1 Mac users but not for Intel users whereas the fix made it work on all devices.