1

I have java 1.7 installed and I am trying to install java 1.6.

I have updated java_home and path variable pointing to the new location, also ran these commands.

sudo update-alternatives --set java /usr/local/java/jdk1.6.0_45/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.6.0_45/bin/javac

My java -version shows me java 1.6 but when I run java class_name, I get the following error

Exception in thread "main" java.lang.UnsupportedClassVersionError: three : Unsupported major.minor version 51.0

When I run the command sudo update-alternatives --config java

 Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/local/java/jdk1.6.0_45/                     1         manual mode
* 3            /usr/local/java/jdk1.6.0_45/bin/java             1         manual mode
  4            /usr/local/java/jre1.7.0_40/bin/java             1         manual mode

Can anyone tell me what I am I missing?

  • Please always include your OS. Solutions very often depend on the Operating System being used. Since you're using update-alternatives, I assume a Debian derived Linux distribution but which one? Also, please edit and add the output of type java and java -version. – terdon Nov 15 '14 at 15:56
0

You need Java 7 to run class files with version 51.0 so you either need to recompile the class or upgrade to Java 7.

Java has lots of links in /etc/alternatives, but there is a tool called update-java-alternatives in the java-common package which makes it easier to maintain them all. That way you don't end up using one version of javac and another of java.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.