0

I've created a small JavaFX app on Os X, using IntelliJ, Java 17 and JavaFX 17.0.x.

The jar file was build as an artefact. The jar file was then converted to a DMG file using jpackage. The app was signed and notarized successfully and it runs perfectly on my local Os X 10.15 machine, like a charm.

When testing the native app an another device, it doesn't open. The console event log app from OS X doesn't show any errors.

I guess it still misses dependencies. How do I find out what is going wrong?

[Update 1]

It seems after moving the original Jar file, the app no longer works on my own device as well. After using the information of James_D, I opened the app package, and it seems the Main jar file is not in the build. So it looks like the jPackage command failed, although it said it was successfully build.

I rerun the command using verbose, and I noticed this in the huge log...

[10:23:10.357] java.io.IOException: Command [/usr/bin/osascript, /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/jdk.jpackage5702973860569608302/config/myFileUploader-dmg-setup.scpt] exited with 1 code
            at jdk.jpackage/jdk.jpackage.internal.Executor.executeExpectSuccess(Executor.java:90)
            at jdk.jpackage/jdk.jpackage.internal.IOUtils.exec(IOUtils.java:205)
            at jdk.jpackage/jdk.jpackage.internal.IOUtils.exec(IOUtils.java:172)
            at jdk.jpackage/jdk.jpackage.internal.MacDmgBundler.buildDMG(MacDmgBundler.java:396)
            at jdk.jpackage/jdk.jpackage.internal.MacDmgBundler.bundle(MacDmgBundler.java:88)
            at jdk.jpackage/jdk.jpackage.internal.MacDmgBundler.execute(MacDmgBundler.java:571)
            at jdk.jpackage/jdk.jpackage.internal.Arguments.generateBundle(Arguments.java:676)
            at jdk.jpackage/jdk.jpackage.internal.Arguments.processArguments(Arguments.java:550)
            at jdk.jpackage/jdk.jpackage.main.Main.execute(Main.java:91)
            at jdk.jpackage/jdk.jpackage.main.Main.main(Main.java:52)

Could this be the raison? How do I fix this?

tmmls
  • 510
  • 1
  • 4
  • 16
  • 1
    Is one an Intel device and one an M1 device? You may need to package the device on an Intel device for it to work on an Intel Mac and, create a different package on an M1 Mac for it to work on an M1 Mac. This is because the packages will include binary components and unless you created a package that includes binary components for both M1 and Intel (which I do not know how to do), then the resultant application will only work on the platform type it was built on. – jewelsea Apr 27 '22 at 23:33
  • *”The console from OS X doesn’t show any errors.”* Can you clarify what you mean here? Even though it’s bundled as an application, you should be able to run this from the terminal. That should show some kind of error message if it’s failing. You’d need to do something like navigating to `/Applications//Contents`, under which you’ll find a JRE and the jar file. You can then launch the JRE and specify the jar file from the terminal. Exact details depend on details of how you set this up, eg if it’s modular or not. Experiment on the one that works, then try the same on the failing one. – James_D Apr 28 '22 at 00:07
  • 1
    @James_D I guess he is referring to the macOS Console app https://support.apple.com/de-de/guide/console/cnslbf30b61a/mac and not a terminal. – mipa Apr 28 '22 at 08:49
  • 1
    You can't just move the jar file because it depends on the other packaged data. You can only move the whole app-folder. – mipa Apr 28 '22 at 08:53
  • @James_D Thanks for all your help. It finally works .. – tmmls Apr 28 '22 at 10:31

1 Answers1

2

I was able to find the problem and solution, thanx to the feedback of @James_D.

Although jpackager displayed a message that the build was successful, the package was incomplete and did not contain the main jar file. There where errors in my jpackage command line statement.

This command line instruction works perfect:

sudo /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/jpackage --input /Users/tm/xDataStore/xSign/myFileUploader/Build --name myFileUploader --type dmg --main-jar myFileUploader.jar --main-class com.myCompany.myFileUploader.Main --icon /Users/tm/xDataStore/xSign/myFileUploader/icon.icns --mac-sign --mac-signing-key-user-name 'Developer ID Application: <removed> (<removed>)' --verbose

2 things I did wrong:

  • my input path was wrong. This must be the root folder path where the jar file is located (but not contain the jar file name)
  • the main jar file path can only be the file name of the main jar file. Do not use the full file path.

After a week of troubles, it finally works...

Ps.

I wish the entire Java app build process could be improved. Visual Studio and Xojo users just have to press a "build" button to have a rock solid executable. Java developers have a lot more work ...

tmmls
  • 510
  • 1
  • 4
  • 16