I have a *nix VM allocated me running CEL6.x version. The JVM pre-built in the image is 1.6 version (which is located under /usr/bin).

Now I need to have Eclipse in the VM. I have a Eclipse executable which needs JVM 1.8 or above.

Unfortunately, i dont have necessary permission to install any software on the VM.

Fortunately, discovered that in one of the mounted path /abc/bin, java-1.8.0_91 is present.

Now I need a way, when we execute java, the one present under /abc/bin (Java 1.8) should be picked rather than the default one present under /usr/bin (Java 1.6).

Any environmental variable i need to change to make this working? Say, JAVA_HOME or something like that.

  • "CEL6.x version" doesn't sound like Ubuntu – steeldriver Apr 9 '18 at 19:30

The update-alternatives command will let you pick which version of Java to use:

user@host:~$ update-alternatives --config java

While it's generally not a good idea to change it manually (use the command above), you can observe that the actual java binary used when you type "java" is controlled by a series of symbolic links:

user@host:~$ which java
user@host:~$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Jan  3 09:03 /usr/bin/java -> /etc/alternatives/java
user@host:~$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Jan  3 09:03 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
  • This allows - for the <name> group and ask the user to select which one to use. When i try this it says, "update-alternatives: error: no alternatives for java" Since i dont have an alternate version made available. So how would i do that? I tried using --install and also --set option. But none of them helped in achieving what i needed. – Darshan L Apr 12 '18 at 8:51

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.