<< Friday C# Quiz: Know Your Closures | Home | Scott Bale: What's So Great About Guice >>

JavaFX FAQ 1: Why The UnsupportedClassVersionError

I was asked a JavaFX Script question yesterday that I think other people may encounter, especially the Mac OS X folks who are trapped in a non-"64-bit-Intel-Leopard" (Core Duo, P5, P4, etc.) machine (who are therefore still without a Java 6 JDK).

Q: I downloaded the JavaFX Script compiler from http://openjfx.java.sun.com/ (which seems to be down at the moment).
So I have a openjfx-compiler directory with dist/bin/javafxc and dist/bin/javafx inside it.
I'm trying code sample 1 from http://java.sun.com/developer/technicalArticles/scripting/javafx/ria_1/.
It compiles with javafxc, but when I run it with javafx I get the following.

JavaFX runtime error

Note that I'm using Java 1.5.
Any idea why this doesn't work?

I seem to remember the same problem being asked on the mailing list a while back. So I went to the mailing list archive to find the answer. Since it took me quite a bit time to find the answer, I thought I'd post the link here.

Tom Ball (on openjfx-compiler mailing list):
You need to compile with "-target 1.5" on the Mac, at least until Apple 
ships Java 6.  The compiler generates Java 6 versioned class files by 
default, since we are extending the latest version of javac.

Tom

Patrick Wright wrote:
> Hi
> 
> I have sync'd with the trunk, built the compiler, and was able to
> compile Jim Weaver's simple test program at
> http://learnjavafx.typepad.com/weblog/2007/11/developing-your.html.
> Trying to run it I get the following:
> 
>> javafx CompiledHelloJavaFX
> Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad
> version number in .class file
>         at java.lang.ClassLoader.defineClass1(Native Method)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
...
Tags :


Re: JavaFX FAQ 1: Why The UnsupportedClassVersionError

The error message is crap. It should TELL YOU what the incorrect version number was, not just say "bad number". Weak.

Re: JavaFX FAQ 1: Why The UnsupportedClassVersionError

The error message is from java and is not unique to javafx. Of course, that doesn't lessen the crappiness of the error message. On the other hand, how would a "bad number 50.0" be a better message than "bad number"?


Add a comment Send a TrackBack