Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a bundled JRE on OSX

Tags:

java

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?

like image 850
Mike2012 Avatar asked Jul 05 '12 23:07

Mike2012


1 Answers

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.

  • It is perfectly legal to bundle the OpenJDK and to redistribute it.
  • The OpenJDK doesn't run only on Lion, I used it on pre-Lion up to Mountain Lion. It needs to be patched to work on a 32 bit OS though.
  • The OpenJDK is in beta quality but it's still acceptable to run a complex Swing application. There are a few issues on OSX, but I described how to fix them in this post.

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.

like image 62
Trasplazio Garzuglio Avatar answered Oct 12 '22 23:10

Trasplazio Garzuglio