Cannot find main class #81
Replies: 3 comments 6 replies
-
Hmm. For starters, I would use JDK 17 or 18 with a bundled JavaFX (Liberica or Zulu). Beyond that I'm not too sure, perhaps try unzipping the jars to make sure things are as you expect... |
Beta Was this translation helpful? Give feedback.
-
Hi there Will, So here it is a couple of years later and I have a repo doing the same thing: Perry$ /Applications/Halyard.app/Contents/MacOS/Halyard After a few hours of troubleshooting I found that I could launch the app using the system Java runtime, which happened to be the same one I was using to embed. openjdk version "17.0.4.1" 2022-08-12 LTS Here is the command I used for that: The application works fine like that, and now I know the problem has something to do with the embedded runtime. So I began to compare a working package to the non-working package. The interesting thing is that I could find no java binary anywhere in the runtime dir for both the working and non-working package. My question to you is, without a Java binary, How does this thing work? |
Beta Was this translation helpful? Give feedback.
-
Well, if you are on macOS nowadays I would recommend using SDKMan to install a JDK. That will typically install the JDK in a well known/OS standard directory and also add it to the path. Beyond that, hard to say as depending on a) your OS configuration b) which JDK variant[s] you have installed and c) what your app is trying to do/dependencies it's hard to say. The idea of this template is that it takes the binaries from the installed JDK and then generates an installer that bundles those binaries. From the perspective of the end user you just get an exe or msi or dmg or whatever and it just looks like an ordinary app. No extra JDK installation needed, it's all bundled inside the app. If you grab the macOS dmg demo app in releases and right click to view the .app guts you'll see the JDK bits inside. I'm assuming that your app is https://github.com/PerryCameron/Halyard - looks like you already have a nice clean Maven build. The way that others have gotten this working is by cloning off the assets of the template, then grabbing your existing pom.xml and src and merging them into the template. You can try doing it the other way, of course - incrementally updating your project by grabbing bits and pieces from the template. That's probably going to generate a lot more errors as you go but you'll learn a lot fixing them. |
Beta Was this translation helpful? Give feedback.
-
So I used your template to update an older java1.8 JavaFX application.
With Eclipse run configurations work
Also 'mvn javafx:run' works
Also 'mvn clean install' works
Here is the issue:
After dropping the app into applications and then double clicking on the app it fails to launch. I see the icon appear but then quickly disappear. The first thing I did was check to see if there was a log in my home directory. There was not so that told me the app wasn't getting that far. I then launched it from the terminal /Applications/Halyard.app/Contents/MacOS/Halyard
What I got was: Missing JavaFX application class com.ecsail.BaseApplication
BTW: /Applications/TestApp.app/Contents/MacOS/TestApp launches TestApp.app with no issues.
So then I opened 2 instances of finder and compared Halyard.app with TestApp.app, by right clicking and "show contents".
The jars are located under Contents/app/
Contents/app/
automation-1.11-8.jar
commons-lang3-3.5.jar
generex-1.0.2.jar
javafaker-1.0.2.jar
maven-jpackage-template-1.0-SNAPSHOT jar.
The maven-jpackage-template jar is the code in our apps.
Anyway, the class BaseApplication was present in the correct location in both of our apps. In fact I compared everything in our two jars and everything looked perfect in both, so this is a head scratcher.
Also, there is a config file in that directory...
Here is the one for TestApp
[Application]
app.classpath=$APPDIR/maven-jpackage-template-1.0-SNAPSHOT.jar
app.mainclass=com.changenode.BaseApplication
app.classpath=$APPDIR/automaton-1.11-8.jar
app.classpath=$APPDIR/commons-lang3-3.5.jar
app.classpath=$APPDIR/generex-1.0.2.jar
app.classpath=$APPDIR/javafaker-1.0.2.jar
app.classpath=$APPDIR/snakeyaml-1.23-android.jar
[JavaOptions]
java-options=-Djpackage.app-version=1.0.0
Here is the one for Halyard[Application]
app.classpath=$APPDIR/maven-jpackage-template-1.0-SNAPSHOT.jar
app.mainclass=com.ecsail.BaseApplication
app.classpath=$APPDIR/automaton-1.11-8.jar
app.classpath=$APPDIR/commons-lang3-3.5.jar
app.classpath=$APPDIR/generex-1.0.2.jar
app.classpath=$APPDIR/javafaker-1.0.2.jar
app.classpath=$APPDIR/jsch-0.1.55.jar
app.classpath=$APPDIR/mysql-connector-java-8.0.30.jar
app.classpath=$APPDIR/protobuf-java-3.19.4.jar
app.classpath=$APPDIR/slf4j-api-2.0.1.jar
app.classpath=$APPDIR/slf4j-simple-2.0.1.jar
app.classpath=$APPDIR/snakeyaml-1.23-android.jar
[JavaOptions]
java-options=-Djpackage.app-version=1.0.0
So the app runs fine in run configurations, mvn javafx:run, and the jar compiles correctly to an executable package. Everything looks fine when you drill into the package. Have any ideas on this one?
BTW I love your template, and am learning a ton of stuff here. Thank you for making this.
Beta Was this translation helpful? Give feedback.
All reactions