I have a problem with my compiled Java application on Ubuntu. It throws UnsupportedClassVersionError
.
I am compiling with a higher JDK version than the one that is configured in my PATH to run Java:
$ javac -version
javac 1.7.0_147
$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
How can I resolve this?
Run either of the following to locate where the location is of that
being used as follows:
or
or
Then once you found the directory, symbolically and forcefully link the bin contents to /usr/bin:
Type following coomand in terminal :
It will ask you for:
I enter 2 as I want to use java 1.7.0_21
This is what you want Java and Ubuntu. I have the same config basically, but I am switching back and forth from Glassfish and Java7. Take a look and try setting up your Java env in a similar fashion
You will also need to do:
Select the desired java compiler from the list provided. For example on Centos 5