Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Application Bundled for Mac doesn't start

Tags:

java

macos

bundle

I'm using jarbundler 2.2.0 as suggested by other answers since the application should run on JRE 1.6 by Apple.

The bundle seems to be right, shows with the appropriate icon but clicking on it doesn't do anything. If I go into it's contents and try double clicking the jar with the main file specified works fine.

Is there a way to see what's happening? Some kind of error or log I can see?

Edit Requested Info.plist. Since the code is private I replaced some stuff with Application:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plist version="1.0">
  <dict>
    <key>CFBundleName</key>
    <string>Application</string>
    <key>CFBundleShortVersionString</key>
    <string>2.2.0</string>
    <key>CFBundleGetInfoString</key>
    <string>Application version</string>
    <key>CFBundleAllowMixedLocalizations</key>
    <string>false</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleExecutable</key>
    <string>JavaApplicationStub</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>beta</string>
    <key>CFBundleIconFile</key>
    <string>SynamicD.icns</string>
    <key>CFBundleIdentifier</key>
    <string>net.sourceforge.javydreamercsw</string>
    <key>Java</key>
    <dict>
      <key>MainClass</key>
      <string>net.sourceforge.javydreamercsw.Main</string>
      <key>JVMVersion</key>
      <string>1.6.*</string>
      <key>ClassPath</key>
      <array>
        <string>$JAVAROOT/Application.jar</string>
        <string>$JAVAROOT/lib\lib1.jar</string>
        <string>$JAVAROOT/lib\lib2.jar</string>
      </array>
      <key>Properties</key>
      <dict>
        <key>apple.awt.textantialiasing</key>
        <string>true</string>
        <key>apple.awt.brushMetal</key>
        <string>true</string>
        <key>apple.laf.useScreenMenuBar</key>
        <string>true</string>
        <key>apple.awt.showGrowBox</key>
        <string>true</string>
      </dict>
    </dict>
  </dict>
</plist>

Contents of PkgInfo:

APPL????

On the Application.app/Contents/MacOS I have the JavaApplicationStub from the Mac Machine.

Resulting file structure:

Application.app
|
---Contents
      |
      ---Info.plist
      ---PkgInfo
      ---MacOS
            |
      |      ---JavaApplicationStub
      ---Resources
            |
             ---Java
                  |
                   ----lib
                        |
                         ---lib1.jar
                        |
                         ---lib2.jar
                  |
                   ---Application.jar
            |
             ---Application.icns

Requested outputs to commands:

~ $ java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
~ $ sw_vers -productVersion
10.8.2
~ $ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    1.7.0_17, x86_64:   "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home
    1.7.0_15, x86_64:   "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home
    1.6.0_43-b01-447, x86_64:   "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_43-b01-447, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home
~ $ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home
~ $ echo $JAVA_HOME

~ $ echo $JAVA_ARCH

~ $ /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
~ $ ls /Library/Java/JavaVirtualMachines
jdk1.7.0_15.jdk jdk1.7.0_17.jdk
~ $ /System/Library/Frameworks/JavaVM.framework/Commands/java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)
~ $ 
like image 339
javydreamercsw Avatar asked Feb 28 '13 17:02

javydreamercsw


People also ask

Does Java not work on Mac?

Installing Java on a Mac is performed on a system wide basis, for all users, and administrator privileges are required. Java can not be installed on a per-user basis. Browser requirements: A 64-bit browser (Safari, for example) is required to run Oracle Java on Mac.

Does Mac come with JDK installed?

All Macs come with a javac shim by default. It bears no relation to whether or not Java is installed.


2 Answers

Those backslashes are certainly wrong, as Mac OS is Unix. Should be:

  <array>
    <string>$JAVAROOT/Application.jar</string>
    <string>$JAVAROOT/lib/lib1.jar</string>
    <string>$JAVAROOT/lib/lib2.jar</string>
  </array>

Since you said you did this on Windows, another thing I would check is file permissions. These files in particular:

  • MacOS/JavaApplicationStub (rwxrwxr-x)
  • Resources/Java/Application.jar (-rw-rw-r--)
  • Resources/Java/lib/lib1.jar (-rw-rw-r--)
  • Resources/Java/lib/lib2.jar (-rw-rw-r--)

And finally, the JVMVersion of 1.6* is not recommended. Try using 1.5+ or 1.6+ instead, as it may be more compatible.

Ruling out all the above, the issue must lie with JavaApplicationStub. Note, from the JarBundler pages:

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.

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.

like image 145
martinez314 Avatar answered Nov 14 '22 23:11

martinez314


Have you tried launching your application via the terminal using open?

open Application.app

This should give you more information on why the application is failing to execute your jar.

Update: Upon running through open yields:

LSOpenURLsWithRole() failed with error -10810 for the file /Users/MacBookPro/NetBeansProjects/SynamicD/dist/SynamicD.app

Referencing https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/LaunchServicesReference.pdf (page 69) shows that the error description is:

kLSUnknownErr -10810 An unknown error has occurred. Available in OS X v10.0 and later.

like image 40
Zack Avatar answered Nov 14 '22 23:11

Zack