user1012037
user1012037

Reputation: 501

Mac Java - Exception: java.lang.UnsupportedClassVersionError

Some mac users are reporting this error. What version can I build the applet so that Mac users can use it?

Thanks

Upvotes: 1

Views: 835

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168825

Use the cross-compilation options of javac to compile the code compatible for a particular version of Java.

Then use the deployJava.js script (linked from the info. page on applets) to check the user has the minimum version.

What version can I build the applet so that Mac users can use it?

As others have mentioned (/alluded to), Macs might support a variety of Java versions. Perhaps a more relevant question is this.

What is the minimum Java version required to run the app.?

I believe 1.4 maybe 1.3 is the minimum required. I've been using 1.6 to build it tho.

The cross-compilation options (especially using -bootclasspath) should answer that question definitively.

I did not mention the -bootclasspath initially since you might have been running a 1.7 SDK that now warns to use it when -source/-target are specified. Using the option requires that you have an rt.jar (the core J2SE classes) of the relevant version to compile against. It checks that the classes, methods & attributes in the code actually exist in the supplied RT jar.

So the upshot is that if you have a 1.6 (or latest) compiler and a JRE of the relevant target version (for the rt.jar as well as run-time testing), it should be possible to compile code compatible for any version.

If I download 1.4 and build with that, it should work for pretty much everyone?

  • It does not require a JDK, just a JRE and the right cross-compilation options.
  • It is impractical to deliver code to 'everyone'. Some people (or whoever controls the PC they use) choose not to install Java, to disable it if it comes standard.

Upvotes: 2

George
George

Reputation: 4109

Check out your JDK or JRE version on the Mac. You are using an older version of JDK or JRE to load a jar file that packaged by a newer version of JDK or JRE than yours.

Upvotes: 1

Related Questions