8

I downloaded jdk-8u91-linux-x64.tar.gz from the Oracle website.

How can I install jdk-8u91-linux-x64.tar.gz?

I have tried apt-get install jdk-8u91-linux-x64.tar.gz and also

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

marked as duplicate by Arronical, David Foerster, muru command-line Apr 30 '16 at 4:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

22

look here

https://stackoverflow.com/questions/6477415/how-to-set-oracles-java-as-the-default-java-in-ubuntu

not the accepted answer but Barracuda's, which I reproduce below:

to set Oracle's Java SE Development Kit as the system default Java just download the latest Java SE Development Kit from [here][1] then create a directory somewhere you like in your file system for example /usr/java now extract the files you just downloaded in that directory:

$ sudo tar xvzf jdk-8u5-linux-i586.tar.gz -C /usr/java

now to set your JAVA_HOME environment variable:

$ JAVA_HOME=/usr/java/jdk1.8.0_05/
$ sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000
$ sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000

make sure the Oracle's java is set as default java by:

$ update-alternatives --config java

you get something like this:

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

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /opt/java/jdk1.8.0_05/bin/java                  20000     auto mode
  1            /opt/java/jdk1.8.0_05/bin/java                  20000     manual mode
  2            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode

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

pay attention to the asterisk before the numbers on the left and if the correct one is not set choose the correct one by typing the number of it and pressing enter. now test your java:

$ java -version

if you get something like the following, you are good to go:

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)

also note that you might need root permission or be in sudoers group to be able to do this. I've tested this solution on both ubuntu 12.04 and Debian wheezy and it works in both of them.

[1]: http://www.oracle.com/technetwork/java/javase/downloads/index.html

  • 1
    Welcome to Ask Ubuntu! While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. I have made the edit for you but next time, please do it yourself. – terdon Apr 29 '16 at 14:41
  • thanks Simone. i used: $ sudo tar xvzf jdk-8u5-linux-i586.tar.gz -C /usr/java now to set your JAVA_HOME environment variable: $ JAVA_HOME=/usr/java/jdk1.8.0_05/ $ sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000 $ sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000 make sure the Oracle's java is set as default java by: $ update-alternatives --config java $ java -version – A.J Apr 29 '16 at 15:50
  • 1
    This worked for me. First check if directory /usr/java is present and if not use mkdir /usr/java. Thanks !! – Walk Mar 30 '18 at 9:28

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