For some time now, our Java application has came pre bundled with a JRE on Windows. We have a little launcher app written in C that make the application use our pre bundled JRE. Now with Apple's crusade to slowly kill Java we have decided that it would be prudent to something similar on OSX. What would be the best way to use a pre bundled JRE on OSX?
I'm the author of the blog post linked by @Daniel in his answer. I successfully bundled the OpenJDK and published a Java app on the Mac App Store.
First, let me correct some issues in the accepted answer.
There's no need to create any script as described in @Matteo's answer, you can use an application called AppBundler, published by Oracle, to create the native executable that will launch your application and create a native bundle. AppBundler will also generate a Info.plist file that contains info on how to launch your application, like the name of the executable to launch, Java arguments etc...
From 10.7.5 and above your app has to be Gatekeeper compatible and signed (so you must enroll in the paid Mac developer program) if you don't want a dialog saying that your app is from an unidentified developer to appear when the user first opens it.
To be deployed on the App Store your app also has to be able to work in a sandboxed environment but it's not a strict requirement if you distribute it outside the App Store.
Note that AppBundler lack some useful features, you may be interested in this fork.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With