The Lazy Log
The Lazy Log

Reputation: 3574

Cannot build DMG from .JAR with javapackager

I've tried building a DMG file from my jar by running the following command:

/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/javapackager -deploy -native dmg -srcdir bin  -srcfiles MyTest.jar -srcfiles p -appclass com.example.Test -name MyTest -outdir deploy -outfile MyTest -v

But it keeps giving the following error message:

Bundler DMG Installer skipped because of a configuration problem: Main application jar is missing.
Advice to fix: Make sure to use fx:jar task to create main application jar.

The funny thing is that if I copy the same folder into another Mac and run the same command, it will build DMG successfully. Therefore I believe it is something related to my config or system environment.

Do you have any idea what is going on and how to fix it?

Upvotes: 0

Views: 1075

Answers (2)

Artur  Dumchev
Artur Dumchev

Reputation: 1330

javapackager was deprecated from java11, and I had the same issue on my local setup even with java8. There is a new tool called jpackage, here is a simple example:

jpackage -t dmg -n AppName --main-class main.core -i . --main-jar AppName.jar --icon ~/Downloads/path-toicons8-log-96.icns

Upvotes: 0

The Lazy Log
The Lazy Log

Reputation: 3574

I found that the order of the option -srcfiles is very important. The last -srcfiles should be the JAR file. In my case, I put -srcfiles p after -srcfiles MyTest.jar, that's why it did not work. Strangely it happened only to some Macs and some JDK, not all of them have this issue.

Upvotes: 1

Related Questions