Search code examples
javamacosswingosx-snow-leopardcompatibility

Java .jar app doesn't start on Mac Os X Snow Leopard


I'm developing a Java app with NetBeans 7.2 and JDK 7. It's set to use the system look and feel. It runs fine on Windows, but when I double click the jar on a Mac OS X Snow Leopard I get:

The Java JAR File could not be launched, check console for possible error messages.

Apparently Snow Leopard is using JRE 6 and can't be updated. I thought Java is all about "Write once run anywhere", but that doesn't seem to be the case.

What wrong here and can I somehow make my app run on this mac?


Solution

  • At a guess, you've compiled the classes with Java 7, and you're trying to run them using a Java 6 runtime. Check the console output to see: java -jar your.jar.

    In NetBeans Tools > Java Platforms, verify that JDK 1.6 is available. In File > Project Properties > Sources > Source/Binary Format, choose JDK 1.6. In File > Project Properties > Libraries > Java Platform, choose JDK 1.6.

    Addendum: You still haven't explained the connection between the source and the platform version.

    Netbeans uses these settings to manipulate the -source and -target options of the Java compiler, javac, which explains more. From the command line, -bootclasspath can be used to ensure that no library classes of a later version are inadvertently used in targeting an earlier version. This Source and Target Options table outlines the history of some significant features.