Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Bundle for Java 7 jar file on MacOS manually

Tags:

java

macos

I'm reading through documentation and have created an app bundle (using Finder, Terminal and TextEdit) as follows:

GUITest.app/
    Contents/
        Info.plist
        PkgInfo
        MacOS/
            JavaAppLauncher
        Resources/
            GenericJavaApp.icns
            Java/
                gui.jar

However when I try double clicking on the finder, the icon has a "no entry" sign on it, and when I double-click, I get: The application "GUITest" can't be opened. -10810

If I try kicking off the JavaAppLauncher manually: ./GUITest.app/Contents/MacOS/JavaAppLauncher I get a dialog with "JRELoadError"

The Info.plist seems pretty straightforward. PkgInfo is just AAPL???? and the JavaAppLauncher is from the http://java.net/projects/appbundler/downloads/download/appbundler-1.0.jar

Could these problems be down to a bad Info.plist or something else?

Here is the Info.plist:

<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>JavaAppLauncher</string>
    <key>CFBundleIconFile</key>
    <string>GenericApp.icns</string>
    <key>CFBundleIdentifier</key>
    <string>gui.GUITest</string>
    <key>CFBundleDisplayName</key>
    <string>GUITest</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>GUITest</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>NSHumanReadableCopyright</key>
    <string>©xirt, 2014</string>
    <key>LSApplicationCategoryType</key>
    <string>public.app-category.developer-tools</string>
    <key>JVMRuntime</key>
    <string>jdk1.7.0_17.jdk</string>
    <key>JVMMainClassName</key>
    <string>main.GUITest</string>
    <key>JVMOptions</key>
    <array>
    </array>
    <key>JVMArguments</key>
    <array>
    </array>
  </dict>
</plist>

Note: the no entry sign was removed by removing the com.apple.quarantine extended attribute: xattr -d com.apple.quarantine JavaAppLauncher But the problem still occurs:

$ open ./GUITest.app
LSOpenURLsWithRole() failed with error -10810 for the file /Users/.../GUITest.app.

The error above can be re-created if the process simply fails. For example, replacing JavaAppLauncher with the following shell script reproduces the problem:

#!/bin/bash
return -1

So, I suppose I have to look at why JavaAppLauncher fails...

like image 507
xirt Avatar asked Feb 17 '26 12:02

xirt


1 Answers

Okay - it took some figuring but there were a number of issues. Ultimately, I recompiled my own JavaAppLauncher from the app bundler source and stepped through it in Xcode (so much for helpful documentation!). https://java.net/projects/appbundler

  1. The JDK reference seemed to be wrong, so removing the JVM Runtime key <key>JVMRuntime</key> <string>jdk1.7.0_17.jdk</string> helped here.

  2. The Java directory needed to be at the Contents level, not Resources.

    GUITest.app/
        Contents/
            Info.plist
            PkgInfo
            MacOS/
                JavaAppLauncher
            Resources/
                GenericJavaApp.icns
            Java/
               gui.jar
    
  3. After fixing these issues, despite two separate applications showing identical diffs, one worked while the other showed error -1080(!). Removing the extended attributes solved the problem: xattr -lr GUITest.app.

see also the java.net page on Packaging: http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

like image 186
xirt Avatar answered Feb 19 '26 02:02

xirt