UnsupportedClassVersionError in upgrading from jdk6 to 7

Currently I'm working on a JavaEE6 project that is being deployed in Glassfish when I decided to upgrade my Java version (to try the new features), then I encountered this issue. Note that I'm running on Ubuntu 12.04

There are several things to look at to solve this issue:

1.) Make sure that you install the java 7 version (I'm using the one from openjdk).
>sudo apt-get install openjdk-7-jdk

2.) Update the default java and javac version your machine is using. Make sure to select the version 7.
>sudo update-alternatives --config javac
>sudo update-alternatives --config java

3.) If you're working on eclipse, set your project's compiler version to 1.7. Right click the project->properties->Java Compiler. Or you can set in in workspace and disable project specific settings of eclipse.

4.) Again on eclipse, add java 7. By clicking Windows->Preferences->Java->Installed JREs and point to where you install openjdk, normally in /usr/lib/jvm/openjdk*.

5.) More on eclipse, matched the execution environment. By opening Windows->Preferences->Java->Installed JREs->Execution Environment. Select JavaSE-1.7 and on the right panel Compatible JREs, select java-7-openjdk*.

6.) And finally make sure that your Glassfish runtime which you set up previously (I assume is still using java 1.6) is updated and is pointing to 1.7. Windows->Preferences->Server->Runtime Environments->Select the Glassfish server you are using->Click edit->change the JRE to 1.7.
UnsupportedClassVersionError in upgrading from jdk6 to 7 UnsupportedClassVersionError in upgrading from jdk6 to 7 Reviewed by Edward Legaspi on Thursday, November 01, 2012 Rating: 5

No comments:

Powered by Blogger.