I have got java 1.7 already installed in my computer(Ubuntu 12.04) and with Java_Home and path properly set.Now I want to install java 1.6 as well because one application I want to use runs only with java1.6.
Here is what I have done so far,
1: I download jdk1.6 and extracted it.
2: Modified the java_home and path to include to point to jdk 1.6.
3: Ran these update-alternative 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_20/bin/javac
Now when I do java -version, I see correct version and I can also compile properly but I do java className I get the following error
Exception in thread "main" java.lang.UnsupportedClassVersionError: three : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
My path variable looks like this
/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/java/jdk1.7.0_40/bin:/usr/local/java/jre1.7.0_40/bin:/usr/local/java/jdk1.6.0_45/bin:/usr/local/java/jdk1.6.0_45/bin
I read somewhere that if java 1.7 comes before 1.6 in path, there will be a conflict. Could that be the case? In that case,how to remove that from path variable?