JarBundler - Java Application Stub

The Java Launching stub file is located inside of your application bundle in the subdirectory "Contents/MacOS/". The default name for this file is "JavaApplicationStub". It is used by the Mac OS X system read the applications plist and then launch the Java VM with the appropriate properties such as the classpath and main class name.

When run on OS X system, the JarBundler ANT task uses the current copy of the JavaApplicationStub from the developer's disk. Starting with JarBundler 1.8 the attribute stubfile can be used to set the name of the JavaApplicationStub file copied from the system framework. If the stub file referenced by the stubfile attribute exists, that file will be used along with it's filename.

When the JarBundler ANT task is used under Windows or Linux, a copy of the JavaApplicationStub must be supplied by the developer. This cannot be built from source but must be obtained from a Mac OS X system.

Java Launching Stub as a Symbolic Link

Creating a bundle with the your current copy of Java Launching Stub could lead to a future situation where the JavaApplicationStub file could become incompatible with a future OS X update.

Under Mac OS X one could replace the "JavaApplicationStub" file with a symbolic link to the user's current copy. This should guarentee that the end user would always be using a current copy of the stub file. I have used this technique on several versions of OS X and have not have had any reported problems with its use.

Obviously, if you have used a stub file name which is different than the one shown in the example below you will have to make changes to both the delete and the symbolic link commands.

This is not yet an option of the JarBundler task but can be accomplished with the following lines of ANT code after building the bundle. NB: This will not work when building under Windows and is untested under Linux.

  <!-- Delete the JavaApplicationStub and replace it with a symbolic link -->
  <!--   which should work on older and future versions of OS X           -->
  <delete file="${release}/${name}.app/Contents/MacOS/JavaApplicationStub"/>
  <exec executable="ln">
    <arg line="-s /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub"/>
    <arg value="${release}/${name}.app/Contents/MacOS/JavaApplicationStub"/>


A Known problem with Java launching stub

In early 2006 an Apple upgrade to Quicktime (7.0.4) caused older versions of "JavaApplicationStub" to fail to start up. These old copies came from developers who first created the application bundle as a directory and then created new applications by replacing the JAR files within the bundle and not replacing "JavaApplicationStub" with a more current copy.