tags:

views:

1422

answers:

4

Hi guys,

I have been trying to open a JAR file on my Mac with no success. It says the JAR file could not be opened and asks me to look for any error messages in my console. Here are the console messages, I suspect the prob is in the first line itself, but I am not from software background, so don't know if this is enough for anyone who knows Java to tell what the issue is. I did update my software, so I am assuming I have the latest version of Java although I don't know how to 100% ensure that - the Java.com website just told me to update the overall software on my Mac and said that will take care of Java's latest version also. Pl help!

5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] Exception in thread "main"
5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] java.lang.UnsupportedClassVersionError: Bad version number in .class file 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.lang.ClassLoader.defineClass1(Native Method) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.lang.ClassLoader.defineClass(ClassLoader.java:675) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.net.URLClassLoader.access$100(URLClassLoader.java:56) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.net.URLClassLoader$1.run(URLClassLoader.java:195) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.security.AccessController.doPrivileged(Native Method) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.lang.ClassLoader.loadClass(ClassLoader.java:316) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.lang.ClassLoader.loadClass(ClassLoader.java:251) 5/26/09 7:48:01 AM [0x0-0x72072].com.apple.JarLauncher[1079] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)

Thanks!

+5  A: 

I'm guessing that the JAR requires Java 6; most Macs only have Java 5 installed.

mipadi
I came here to say this.
Paul Tomblin
+3  A: 

UnsupportedClassVersionError - there's your culprit. The class file was generated on a later version of the JDK than the JRE you're trying to run it on.

paxdiablo
I tried updating my version of Java using the links in the message below but I still get the same message.. any thoughts??
From that link: "This update does not replace the existing installation of J2SE 5.0 or change the default version of Java." - your default Java is still JRE5. You need to figure out how to run your classes under JRE6. Can't help you there, I'm not a Mac guy.
paxdiablo
+1  A: 

Currently Macs ship with have Java 1.5. Java 1.6 can be downloaded for 64 bit Intel Macs here: http://support.apple.com/downloads/Java_for_Mac_OS_X_10_5_Update_1. From http://support.apple.com/kb/HT1856:

This release does not change the default version of Java. This release is only for Mac OS X 10.5.2 and later, and should not be installed on earlier versions of Mac OS X. This release is for 64-bit, Intel-based Macs only and cannot run on PowerPC-based or 32-bit Intel-based Macs.

Clint
You can get a 32-bit Java for Intel athttp://landonf.bikemonkey.org/static/soylatte/or from the MacPorts openjdk6 port.
Blair Zajac
+4  A: 

The above exception is thrown when a JVM encounters an unsupported class version. This occurs when the JVM encounters a class built for a later JVM. So you need to upgrade your VM, then change your default Java.

Here's how to change your default:

Type 'java preferences' into Spotlight. You'll see the 'Java Preferences' utility. Run that, and you can change the default Java instance to what you require (probably Java 6).

EDIT: That utility is in Application/Utilities/Java. Using Spotlight seems an easier way to find it though!

Brian Agnew
This needs to be upvoted since it is the only answer that mentions the problem and the solution
willcodejavaforfood
http://stackoverflow.com/questions/908680/jar-file-not-opening-on-a-mac/908861#908861 explains how to get Java 6 on your Mac if you don't already have it.
Bill Michell