I am using Ubuntu 14.04.1 LTS, x64 architecture, and I specifically need to install Oracle Java. Now I know there are some instructions on the website which I follow but the same website does not recognize it. Can any one please help me with some instructions? Thanks!
1 Answers
Using a PPA (Obsolete)
Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence this method no longer works and exists because of historical reasons.
You can use WebUpd8 PPA (this will download the required files from Oracle and install JDK 8):
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Are PPA's safe to add to my system and what are some “red flags” to watch out for?
Also ensure your JAVA_HOME
variable has been set to:
/usr/lib/jvm/java-8-oracle
For this you can use the following command (see step 3 of Manual Install to see how to make it permanent):
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
Manual install
The tar.gz provided by Oracle don't have an actual installation process. You just extract those files to a location you want and add them to your path. So the process is the following:
- Download a
.tar.gz
from Oracle (here I will be usingjdk-8u20-linux-x64.tar.gz
); - Extract it to somewhere;
Move the extracted folder to
/usr/lib/jvm
. This is not required but it is the place where Java runtime software is installed, and where tools like IDE's may search for it:sudo mv /path/to/jdk1.8.0_20 /usr/lib/jvm/oracle_jdk8
Before addin this jdk as an alternative, you can see that the new alternative is not listed:
sudo update-alternatives --query java sudo update-alternatives --query javac
Next, add the new jdk alternatives (2000 is the priority and feel free to pick a different number):
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk8/jre/bin/java 2000 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk8/bin/javac 2000
Now you should see the new jdk listed and you can switch between the alternatives with this command:
sudo update-alternatives --config java sudo update-alternatives --config javac
Create a file
/etc/profile.d/oraclejdk.sh
with the following content (adapt the paths to reflect the path where you stored your JDK):export J2SDKDIR=/usr/lib/jvm/oracle_jdk8 export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin export JAVA_HOME=/usr/lib/jvm/oracle_jdk8 export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db
Done! Those paths will only be recognized after you logout or restart, so if you want to use them right away run source /etc/profile.d/oraclejdk.sh
.
-
Thanks again and I accept the answer but please, can you show me the manual version, I mean how to install the tar.gz file. – Dan Sep 07 '14 at 14:18
-
I'm going to assume you know how to follow the instructions to install the tar.gz file. The problem is that website doesn't have java 8. So how did you download it? Did you go to oracle.com? – Chan-Ho Suh Sep 07 '14 at 14:23
-
-
2@user244986 See my edit. Please note that the PPA process is more or less the same as the manual one (ie the installation of that package only downloads a script to do basically the same). – Salem Sep 07 '14 at 15:20
-
Sorry I didn't even see yes, you are rigth it was JDK 7 all this time, just one question, how did you know which wariable to export, and why? – Dan Sep 07 '14 at 16:17
-
@user244986 The only needed exports are the PATH one and maybe JAVA_HOME (some programs use it). The others are copied from the package
oracle-java8-installer
– Salem Sep 07 '14 at 21:08 -
using ubuntu 14.04.1 installing by ppa by those 3 lines worked thx – Jacek Pietal Oct 21 '14 at 17:06
-
use
sudo apt-get install oracle-java7-installer
if you want to install java 7 – Tuna Jun 23 '15 at 01:57 -
Last version for Ubuntu 14.04 Trusty is 8u45+8u33arm-1~webupd8~1 to get JAVA 8u51 (last version) I found the solution at: instalando-o-oracle-jdk-8-no-ubuntu-14-04-lts (pt-br) – Moreno Jul 22 '15 at 21:29
-
-
It seems that the
oracle-java8-installer
already puts in the file/etc/profile.d/jdk.sh
that makes the exported variables permanent. – Evgeni Sergeev Jan 05 '17 at 09:52 -
jdk/jre
with this script – Jahid Dec 24 '15 at 11:01