Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X JavaApplicationStub for Java 6 AND Java 7

Tags:

java

macos

I am developing a cross platform Java application with native executables. For Mac OS X I use Jarbundler as an ANT task to create the App package.

Now that Oracle released Java 7 and its own ANT task "Appbundler" I got a problem.

Using the native Mac OS X JavaApplicationStub with Jarbundler only works for Apple Java 6, and using the Oracle JavaApplicationStub with Appbundler only works for Java 7.

I do understand the background of this very well, but I was wondering whether there is a JavaApplicationStub available that works with both Java 6 and Java 7. I haven't found one so far...

And btw: does the JavaApplicationStub has to be a native C/C++/C# binary? Or could it also be an executable shellscript?


Update:

A shell script is a possible alternative to a native JavaApplicationStub.

I extended Ian Roberts basic shell script and released it on GitHub as "universalJavaApplicationStub". It now supports both Apple Java 6 and Oracle Java 7 and also both Info.plist styles for Java properties in the application bundle (Oracle introduced new property keys). Feel free to use it!

like image 938
ToFi Avatar asked Oct 02 '22 08:10

ToFi


1 Answers

The main executable inside a bundle can be a shell script, so you could use a script that first tries /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java (the java 7 JRE install location), and falls back on /usr/bin/java if that is not found. The latter will run the most recent JDK that has been installed (6 or 7) and should prompt to install Java 6 if there is no JDK found at all.

like image 139
Ian Roberts Avatar answered Oct 28 '22 19:10

Ian Roberts