There are two standard types of installation available are JDK and JRE. JDK (Java Development Kit) provides the ability to develop a new Java application, which includes Java compiler. JRE (Java Runtime Environment) provides the runtime environment for any Java application with applets. The Java developers required to install JDK and JRE both on their system to create new Java Applications.
- Read this => Install Oracle Java 11 on Ubuntu 16.04 LTS (Xenial)
- Read this => Install Oracle Java 11 on Ubuntu 18.04 LTS (Bionic)
Use this tutorial to Install Oracle Java 8 on Ubuntu 18.04 LTS, 16.04 LTS, 14.04 LTS and LinuxMint 19, 18 using PPA. Follow the below steps to Install Oracle Java 8 on Ubuntu command line.
Step 1 – Install Oracle Java 8 on Ubuntu
You need to enable additional repository to your system to install Java 8 on Ubuntu VPS. After that install Oracle Java 8 on an Ubuntu system using apt-get. This repository contains a package named oracle-java8-installer, Which is not an actual Java package. Instead of that, this package contains a script to install Java on Ubuntu.
Run below commands to install Java 8 on Ubuntu and LinuxMint.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
Step 2 – Verify Java Inatallation
The apt repository also provides package oracle-java8-set-default to set Java 8 as your default Java version. This package will be installed along with Java installation. To make sure run below command.
sudo apt-get install oracle-java8-set-default
After successfully installing Oracle Java 8 using the above steps, Let’s verify the installed version using the following command.
java -version java version " 1.8.0_201 " Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Step 3 – Setup JAVA_HOME and JRE_HOME Variable
After installing Java on Linux system, You must have to set JAVA_HOME and JRE_HOME environment variables. Which is used by many Java applications to find Java libraries during runtime. You can set these variables in /etc/environment file using the following command.
cat >> /etc/environment <<EOL JAVA_HOME=/usr/lib/jvm/java-8-oracle JRE_HOME=/usr/lib/jvm/java-8-oracle/jre EOL
All done, you have successfully installed Java 8 on a Linux system. You may also need to install Tomcat server to run your Java web application. Use our another tutorial to Install Tomcat 7 or Install Tomcat 8 or Install Tomcat 9 on Ubuntu, Debian, and LinuxMint systems.
Linux Mint 19.1, couldn’t do the last step as the guide says. Ended up doing:
sudo nano /etc/environment
Paste in:
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
Save and exit.
Thank you for the guide!
This is simple and extremely easy explanation
But live-streaming of the game can affect their job and makes these enjoy theirs favored game on laptop or pc.
If they bests the seller he gets twice the total amount
of money inside the payout than he’d have if he had gained without doubling.
Location: http://download.oracle.com/otn-pub/?AuthParam=1521892631_53f4fd9f2a836d690ba6d31c8b160b91 [following]
–2018-03-24 11:55:11– http://download.oracle.com/otn-pub/?AuthParam=1521892631_53f4fd9f2a836d690ba6d31c8b160b91
Connecting to download.oracle.com (download.oracle.com)|2.21.188.165|:80… connected.
HTTP request sent, awaiting response… 404 Not Found
2018-03-24 11:55:12 ERROR 404: Not Found.
Hi Scott,
I have checked commands and this is working for me. Which operating system version are you using?
W: Falhou ao buscar http://archive.ubuntu.com/ubuntu/dists/vivid-backports/universe/binary-i386/Packages 404 Not Found [IP: 91.189.88.149 80]
sudo apt-get install oracle-java8-installer
sudo: não foi possível resolver máquina leni
Lendo listas de pacotes… Pronto
Construindo árvore de dependências
Lendo informação de estado… Pronto
Alguns pacotes não puderam ser instalados. Isto pode significar que
você solicitou uma situação impossível ou, se você está usando a
distribuição instável, que alguns pacotes requeridos não foram
criados ainda ou foram retirados da “Incoming”.
A informação a seguir pode ajudar a resolver a situação:
Os pacotes a seguir têm dependências desencontradas:
oracle-java8-installer : Depende: java-common (>= 0.24) mas não é instalável
Recomenda: gsfonts-x11 mas não é instalável
Recomenda: oracle-java8-set-default mas não será instalado
E: Impossível corrigir problemas, você manteve (hold) pacotes quebrados.
Hello
Connecting to download.oracle.com (download.oracle.com)|104.122.105.69|:80… connected.
HTTP request sent, awaiting response… 404 Not Found
2018-01-22 13:59:51 ERROR 404: Not Found.
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
I am getting this error while running install command on terminal on linux mint 17.2.
Hi Ankit, The webupd8 team has not updated the package yet to PPA. For the time, You can download packages to install Java 8.
https://drive.google.com/file/d/1l8NTWhZrwYjvjRMXvAgTNXbExJ08eIjU/view
when i do this all i get is
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (–configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
Hi Bill, The webupd8 team has not updated the package yet to PPA. For the time, You can download packages to install Java 8.
https://drive.google.com/file/d/1l8NTWhZrwYjvjRMXvAgTNXbExJ08eIjU/view
Great information. Appreciate the time you took to share this feedback for us computer nerds. Love your blog too. Java is still one of the best options out there.
step 1 Can do add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer allso little bit easy 🙂
hi,
there is an error with python-samba while installing oracle-java8-installer.
[/var/cache/apt/archives/python-samba_2%3a4.3.11+dfsg-0ubuntu0.16.04.9_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)]
how can i solve this problem?
i’m not being able to edit the etc/environment file!!!
please help?!
Hello:
You you either open ‘Files’ or ‘nautilus’ with root privileges, you will be able to open the etc/environment file, edit it and save afterward.
the easiest way is to do it through the terminal using sudo for root access (which enables you to edit sensitive files)
$ sudo gedit /etc/environment
add the lines
then save.
done.
This seems to install JRE _not_ JDK as the title of the article states.
Several people have pointed this out in the comments yet these queries remain unanswered.
Perhaps the title of the article is incorrect…
Hi Tim,
This installs JDK and JRE both. After installation you can check install java compiler.
$ javac -version
javac 1.8.0_111
Thank you! This works Great! I was also able to integrate Apache Solr on my website
I am thinking about keeping this up and going on my vps server
Hello, i f i understand this will install JDK too. But i cant find my JDK directory.
any help or explanation ? thank you in advance
I didn’t get a JDK downloaded either. Does anyone have a suggestion ?
I don’t like it.. It’s too easy.
Do you have a harder example?
This is simple and extremely easy explanation
I want know becouse we make donwload of archive on site of oracle and that file i dont can install
1-up!!! Thanks! you saved my day 🙂
Thanks for your suggestions, this solution is fast and understandable. i owe you one 😀
that is the best guide of the INTERNET, thanks man.
Thank you maaaan!
I’ve installed java 1.8 on two devices thanks to this beautiful simple process
🙂 you da man thanks!
Great guide.
Thanks!
If you get “Cannot add PPA ‘ppa:cooperjona/lightread’ . Please check that the PPA name or format is correct.” error
sudo -E add-apt-repository ppa:ppaname/ppa
instead of
sudo add-apt-repository ppa:ppaname/ppa
thanks
Genio, muchas gracias. Saludos desde Argentina!
This saved my day! Thank you!
This saved me a whole day of manually doing it myself. Thanks so much!!
Great step-by-step process document!! Thanks.
thanks!
Thanks a lot! You all helped me a lot!
nice documentation
i already had java7. after installing java8, java- -version still gives jdk7… whats the solution?
have u got any solution? for this ….
Thanks for the great instructions!
Thank you !
Thank you very much !!
Thank You so much
Thank bro none of the site help out on google but u r site instruction was extremely perfect….
This article was extremely helpful. Please keep posting Linux and Java related articles.
Thanks for a simple and great HOWTO! 🙂
hi guys i am getting this error)
(http://download.oracle.com/otn-pub/java/jdk/8u72-b15/jdk-8u72-linux-i586.tar.gz
Connecting to download.oracle.com (download.oracle.com)|180.149.61.152|:80… connected.
HTTP request sent, awaiting response… Read error (Connection reset by peer) in headers.
Retrying.)
upto try:5 after that download fail NOT inst error please help
Encountered the same issue – i had to modify the timeout settings in /var/lib/dpkg/info/oracle-java8-installer.postinst to make it run. Sadly, the installer script doesn’t use the system-wide /etc/wgetrc but creates its own wgetrc each time it runs. So, you’ll have to search for the line “echo “timeout = 15″ >> wgetrc” in the postinst file i’ve mentioned above. Now, just set a longer timeout or remove the line completely.
Thank you very much
It is not working for me.
Hi,
What issue are you facing ?
Thanks man. It works perfectly.
Muy útil, muchas gracias.
Very useful tutorial…
Thank you
hey!!! so usefull!!!! thank a lot!!!!! 😀
Thanks dude searched everywhere for guides but yours is the best and easiest.
Thank you 😉
Hey, i’am new with linux and its very usefull thanks for the tutorial.
Thank you very much for this. It helped a lot!
I’m getting an error when running the command:
sudo add-apt-repository ppa:webupd8team/java
The error is:
Cannot add PPA: ‘ppa:~webupd8team/ubuntu/java’.
ERROR: ‘~webupd8team’ user or team does not exist.
Hi Ian,
Its still working for me. Please confirm what OS version are you using ?
Thanks but it’s not working for me, this is the message i got:
~ $ sudo apt-get update
E: Type ‘sudo’ is not known on line 1 in source list /etc/apt/sources.list.d/mono-xamarin.list
E: The list of sources could not be read.
Very nice, simple and useful
Sure wish this wasn’t the first item coming up in a google search of “installing java 8 jdk on ubuntu” because this isn’t the jdk!
I agree with you comment !!! It’s not a JDK and only a Runtime then, no option to compile (no javac compiler)
Thanks a lot!
Nice article. So the reference in my blog yes
Thanks a lot
thanks
Thanks for that short advice, for now everything is working 😉 and let it stay in this way 😉
Thank you!
thank, ..thank you very much, very nice work
Very Nice, thanks!
you follow this post and enjoy java8. very nice work done by techadmin.
Thanks dude ° this information was util.
Good job!
Does not work trows class not found exception
everything went in a breeze – cool
thanks
looking for manual procedure to do stepbystep as well
Thanks a lot.
Very helpful.
Thanks man!! Worked like a champ!
Muito obrigado amigo.
Thank you very useful
Thanks
While installing throw sha256sum mismatch jdk-8u60-linux-x64.tar.gz
please help me to out this problem
Thank you so much……Really really helped alot….. 🙂
Is there a way to get it to move up from 51 to 60? The website says I am behind!
Thanks very thamkful!!
Really helpful information.
Good One!
Webupd8 Java PPA DOWN!!!!! When will it be updated?
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://ppa.launchpad.net trusty Release: The following signatures were invalid: BADSIG C2518248EEA14886 Launchpad VLC
W: Failed to fetch http://ppa.launchpad.net/webupd8team/java/ubuntu/dists/trusty/Release
W: Some index files failed to download. They have been ignored, or old ones used instead.
thankyou somuch
Thank you sharing a such helpful article
idk how to install this
Hi Rahul,
I am new to Ubuntu. I tried the setps to install jdk 1.8.
While setting environment, I found the error
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/rt.pack
jsse.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/jsse.pack
charsets.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/charsets.pack
localedata.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/ext/localedata.pack
jfxrt.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/ext/jfxrt.pack
plugin.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/plugin.pack
javaws.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/javaws.pack
deploy.jar…
Error: Could not open input file: /usr/java/jre1.8.0_45/lib/deploy.pack
/var/lib/dpkg/info/jre1.8.0-45.postinst: line 641: /usr/sbin/alternatives: No such file or directory
dpkg: error processing package jre1.8.0-45 (–configure):
subprocess installed post-installation script returned error exit status 127
Setting up oracle-java8-set-default (8u45+8u33arm-1~webupd8~1) …
Errors were encountered while processing:
jre1.8.0-45
E: Sub-process /usr/bin/dpkg returned an error code (1)
What should I do to set environment ?
Same here, HARSHITA.
Worse: I can’t install any package since I’ve tried to install this using this tutorial. Can someone help please?
Zoli
EDIT: Maybe a helpful hint, I did a…
java -version
…this shows me…
java version “1.9.0-ea”
Java(TM) SE Runtime Environment (build 1.9.0-ea-b70)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b70, mixed mode)
So the error messages seem to come from an older installation, that I have to remove. But how?
Zoli
Very helpful article.
Very helpful,
Thanks !!!
Very helpful article. Thanks.
Hi,
I would like to thank you for helping the non techs like myself first. Could you help me with a problem I get? I am using LM 17.1 and trying to do the installation I get the Binary Code License Agreement display at mt terminal window. There is no way to click ok or accept those terms, failing which the installation aborts. Can you tell me a way around, or what am I doing wrong?
Thanks
Amit
use arrow keys to move, enter to accept
Thank you!! It works!.
Thanks for the info! very helpful…
Thank you so much, this helped a lot !!!!
Thanks from a spanish user!
Thanks! It helped a lot!
if i search, do i have java?, and enter site is says this plugin is not accepted,what i have to do?
Hi Habdul,
Do you mean java is working with browser ? If yes which browser are you using ?
Thank you for kind article to install java 1.8 in Ubuntu 14.04.
It works well. 🙂
Will it work for Ubuntu 14.10?
This is very handy, thank you. And thank you to the Webupd8 Team!
thank you, greetings from México.
You made my day,, thanks allot
Hi,
I could install java 8 as you wrote, but I still can not set java 8 as a default JRE. And when I would like to add it to the installed JREs I cant find it. Where should it be?
Thank you!
thanks for post !! it was very helpful for me !
Thanks for the guide.. worked fine for me
Thank you very much. This is really helpful.
Awesome! very helpful!
Very useful. Thank you.
Very Easy for install Java in Ubuntu 🙂
Nice Job
great! i always wonder why we haven’t something like a repo to install jdk!
great work
Thanks a lot. Quick, easy and it installs both JDK and JRE version 8!
Wonderful and helpful.
A written tutorial on how to install using the already downloaded tar.gz file will be helpful too. Thanks
This installs the JRE not the JDK/SDK. Is not the same ….
Nice tutorial!
But now, How do you uninstall it?
Packages can be removed with
>sudo apt-get –purge remove packageName
apt-get remove may some times leave behind some files.
–purge will remove all files.
Hi, whish all of costum installs have these very good install help,
saves lots of time , thx,
Hi,
I am getting an error stating the following. Please help.
Cannot add PPA: ‘ppa:webupd8team/java’.
Please check that the PPA name or format is correct.
no problem here with sudo, name (and all further instructions are correct)
Yeah.. same problem here
Thanks man, saved me some time 🙂
thanks! 🙂
Thank you very much, this helped a lot
Very good, help so much
Thank’s for this article!
Thanks! Very helpful.
you guys rock
Thank you so much!
Thank you!
thank you very very much
Missing the – in java -version
Woops! Retract that!
many thanks, this helped a lot!
Thanks!
I can´t access my bank with open-jdk, only with oracle-java
Useful Information, Thanks
Nice tutorial
Greetings from Mexico Wey!! :3
Thanks!!!! God Thanks!!!!
Hi, these information is very useful. Thank you very much.