OS X and Java: UnsupportedClassVersionError

A couple of months ago, Apple finally released a version of Java 6 for OS X. With Java 5 fast approaching its end of service life, many Mac developers, including the couple of us who use OS X in production at my office, were eagerly awaiting the release of a production-quality Java 6.

There is one issue, however, with the implementation of Java 6 for the Mac: it only supports 64-bit processors. This isn’t huge for any of us, but it makes Java selection a bit confusing.

At first, I tried to use the OS X Java Preferences to change the default to Java 6. That didn’t work across the board, and I discovered that the link to Java in /System/Library/Frameworks/JavaVM.framework/Vresions/Current didn’t seem to be pointed at Java 6 like I believed it should. I manually set the link to 1.6, but Eclipse isn’t compatible with a 64-bit JVM. So, I decided to manually set the version and path for Tomcat via a statement in my deployment script. Since I was trying to get this done quickly, I put off moving the JAVA_HOME statement into my default .profile which, as I discovered, was a fairly big mistake.

It was then that I discovered something pretty interesting. If you start up Tomcat with one JAVA_HOME and then try to shut it down with another JAVA_HOME, it throws the following:

UnsupportedClassVersionError: Bad version number in .class file

Makes sense, and placing the Java 6 path JAVA_HOME in my .profile fixed the problem, but it proved to be an hour or so of ripping-my-hair-out frustration before I figured it out.


About johnnywey

Welcome to A Regular Expression. This blog is designed to reflect my thoughts on life, music, software design, Apple, faith, philosophy, and whatever else I can think of.

Posted on June 21, 2008, in Apple, Java, Leopard, Programming. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: