<detailed instructions go here once MACOSX_PORT-105 is complete>
A prototype launcher stub is present in the source code at:
http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/file/tip/src/macosx/bundle/JavaAppLauncher/
The Xcode project file in that directory will build a shell .app with the launcher stub and an example Info.plist.
The next steps for this code is to be adapted into the JDK's proper Makefile-driven build system, and to create an artifact in the standard JDK bundle. After that, a script or Ant target which can be driven by and IDE should take that artifact and a application descriptor to create a proper .app.
Contributed steps to bundle from the macosx-port-dev@openjdk.java.net mailing list:
-----------------------------------------------------------
-----------------------------------------------------------
STEP 1. Checkout, download, install & build the MacOS OpenJDK package as described on the Oracle OpenJDK Mac OS X Port page:
STEP 2. Identify & launch the JavaAppLauncher.xcodeproj located in your
/YOUR_INSTALL_PATH/jdk7u-dev/jdk/src/macosx/bundle/JavaAppLauncher/ directory.
STEP 3. In the Xcode project repair any undefined file paths. These would be indicated in the files tab in the Xcode project left side bar in red. I had to update the 1.7.0.jdk & 1.7.0.jre paths to the bundles stored in /YOUR_INSTALL_PATH/jdk7u-dev/build/macosx-amd64/j2sdk-image/ directory and the /YOUR_INSTALL_PATH/jdk7u-dev/build/macosx-amd64/j2re-image/1.7.0.jre respectively. I also had to update all the files in the include diretory which included:
/include/classfile_constants.h
/include/darwin/jawt_md.h
/include/darwin/jini_md.h
/include/jawt.h
/include/jdwpTransport.h
/include/jni.h
/include/jvmti.h
/include/jvmticmlr.h
All the above I found in the /YOUR_INSTALL_PATH/jdk7u-dev/build/macosx-amd64/include/ directory.
I also need to find the /frameworks/Cocoa.framework/Headers/Cocoa.h reference. I used the one hosted in /System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/ directory.
I specified all the 'Location' paths in the Xcode UI as [Absolute Path]
STEP 4. Build the project in Xcode. If all goes well you'll find the product JavaAppLauncher.app which will give you a template to base your own app bundle from. Xcode will give you the path of the project output. Mine was :
/Users/me_myself_and_I/Library/Developer/Xcode/DerivedData/JavaAppLauncher-aukxmnehzjucapfxrjaqkfoicyak/Build/Products/Debug/JavaAppLauncher.app
STEP 5. Copy/Paste the JavaAppLaucher.app/Contents/MacOS/JavaAppLauncher stub as well as the JavaAppLaucher.app/Contents/Plugins directory (the entire contents) into your own Java Application Bundle. Also copy 'Your_Executable_JarFile.jar' into a YourApp.app/Contents/Java/ directory.
STEP 6. Edit your info.plist to look something like: NOTE: /$JAVAROOT/ is now a /Content/Java directory an not '/Contents/Resources/Java' as in the older bundles.
-----------------------------------------------------------
-----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>11C74</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>Splendid City</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>anexten</string>
</array>
<key>CFBundleTypeIconFile</key>
<string> anExten.icns</string>
<key>CFBundleTypeName</key>
<string>My Special Project File</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>TEXT</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>JavaAppLauncher</string>
<key>CFBundleGetInfoString</key>
<string>Amazing App® version 7.0 Copyright 2012 Company Software</string>
<key>CFBundleIconFile</key>
<string>AmazingApp.icns</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.AmazingApp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Amazing App</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>7.0</string>
<key>CFBundleSignature</key>
<string>AZts</string>
<key>CFBundleVersion</key>
<string>7.0</string>
<key>DTCompiler</key>
<string></string>
<key>DTPlatformBuild</key>
<string>4D502</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>11C74</string>
<key>DTSDKName</key>
<string></string>
<key>DTXcode</key>
<string>0421</string>
<key>DTXcodeBuild</key>
<string>4D502</string>
<key>JVMInfo</key>
<dict>
<key>Arguments</key>
<array/>
<key>ClassPath</key>
<string>$JAVAROOT/Your_Executable_JarFile.jar</string>
<key>JRE</key>
<string>1.7.0.jre</string>
<key>MainClass</key>
<string>MyMainClassImpl</string>
<key>Properties</key>
<dict>
<key>apple.laf.useScreenMenuBar</key>
<string>true</string>
</dict>
</dict>
<key>LSMinimumSystemVersion</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 Company Software. All Rights Reserved.</string>
</dict>
</plist>
-----------------------------------------------------------
-----------------------------------------------------------
If all goes well your app will get launched with the screen menu bar by double clicking it in the finder UI and will be running with the embedded jre.
Currently my app is launching with this but for some reason, (I'm using reflection with my splash screen to launch the real main class) my second main calling is only happening after the second invokation of the launcher code.
2 Comments
J. Duke
Any tip on this?
J. Duke
A colleague, Marco Dinacci, has gotten our app (Moneydance) packaged and ready for the app store and has written up a detailed description of what was necessary, including code and configuration. The details are listed here: http://www.intransitione.com/blog/take-java-to-app-store/