0

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?

1 Answer 1

1

you have both jdk 1.6 and 1.7 in your path remove the older version from the path

Sign up to request clarification or add additional context in comments.

3 Comments

how do I remove it from path? I just add path in .profile. Also can't I have two java version installed?
if this /home/wrong/dir/ is the directory you want to delete do this PATH=echo $PATH | sed -e 's/:\/home\/wrong\/dir\/$//'
why did you put a $ in sed?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.