4

First off I'm using Ubuntu 14.04

I was following this video to set up a Java JDK and at the end he uses

java -version

to see his current version number. The Version I installed was 1.8.0_66 but mine returns

java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

But when I check for the JAVA_HOME that seems to be correct

user@user:~$ $JAVA_HOME
bash: /usr/lib/java/jdk1.8.0_66: Is a directory

Where have I gone wrong? The additional resource he uses in the video is this and I feel like step 5 is maybe where things are going haywire, even though I do update the file name version before I run the script.

Any ideas? Anything is much appreciated thank you.

After digging around online I ran the line

update-alternatives --config java

which returned with

There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/java/jdk1.8.0_66/bin/java               1         manual mode
  2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode

Press enter to keep the current choice[*], or type selection number: 

I've tried entering in 1 and sudo 1 etc but the java version doesn't change. And it just redisplays the above code, without changing the default. How do I correctly enter this? If this is even how to do it. According to this I already had java installed in the jvm folder. Is it necessary to use the latest version of java or should I use this preinstalled version? I'm new to java so I'm not very experienced on what I need to be doing.

2
  • 1
    Run sudo update-alternatives --config java and then enter 1..should do it..
    – heemayl
    Oct 22, 2015 at 1:26
  • 2
    Try sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jdk1.8.0_66/bin/java 1100
    – heemayl
    Oct 22, 2015 at 1:34

1 Answer 1

1

heemayl's answer was it.

"Try

 sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jdk1.8.0_66/bin/java 1100

" I did this for the scripts and they went through correctly and java -version now reads the correct one. Thank you!

2
  • my opinion , give chance to @heemayl to post answer =)
    – Ravan
    Oct 22, 2015 at 2:31
  • @heemayl I have unmarked my answer if you would like to post yours
    – Alkarin
    Apr 25, 2017 at 1:18

Not the answer you're looking for? Browse other questions tagged .