简体   繁体   中英

Mac OS X JavaApplicationStub for Java 6 AND Java 7

I am developing a cross platform Java application with native executables. For Mac OS XI 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!

I think I found the answer in @IanRoberts answer to this topic "Java AppBundler application pointing to JRE defined by JAVA_HOME" .

He suggests to replace the JavaApplicationStub with a custom shellscript to support both Java 6 and Java 7.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM