How do I install Java, including in my browser, so websites with Java work?


15 Answers 15


There are several implementations of Java. The three most common implementations when talking about it for Ubuntu are:

  • OpenJDK: The primary goal of the OpenJDK project is to produce an open-source implementation of the Java SE Platform (6 and 7). This is the default version of Java that Ubuntu uses and is the easiest to install.
  • Sun Java: Sun Java is the reference implementation for Java 6. Its support has been discontinued in Ubuntu.
  • Oracle Java: Oracle Java is the OpenJDK Java Se Platform version 7 implementation from Oracle. Oracle introduced with this implementation a license that prevents distribution.

Since Ubuntu 11.10 (Oneiric Ocelot) and due to license issues Ubuntu will no longer distribute Oracle's JDK and JRE. Also, previous versions supplied on PPAs suffer from security issues and are not recommended to be installed on any Ubuntu system.

There are no more supported .deb releases from Ubuntu with reference to Sun Java or Oracle Java, Ubuntu officially supports OpenJDK and OpenJRE implementation of Java which is the base for Oracle's own implementation.

OpenJRE is the official implementation of Java Runtime Environment (JRE) for your Ubuntu systems and should suffice to run any Java program that you might require and it's included in the main repository and it's easily installable.


By opening a terminal and typing

sudo apt-get install default-jre

this installs openjdk-11-jre (at the time of writing this, you may install a newer java version in the future, which is now, if it installs a different openjdk version I guess)

The openjdk-11-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the default-jdk package:

Also important is to install the wrapper for supporting Java applications on your web browser, the Iced-Tea Java Plugin.

IcedTea Plugin

Install via the software center

Or via a terminal

sudo apt-get install icedtea-plugin

Or look for icedtea-plugin in the Ubuntu Software Center.

To make sure that you are running the correct version of Java, use this command to set your choice:

sudo update-alternatives --config java

java -version should display the choice you previously made.

If you need to install OpenJDK-JRE 6 or OpenJDK-JDK 6

openjdk-6-jre (click to install) is available for installation for Ubuntu 8.04 (Hardy Heron) and up.

Install it with

sudo apt-get install openjdk-6-jre

Or if you need the developers' package, openjdk-6-jdk (click to install), install it with:

sudo apt-get install openjdk-6-jdk

A version of the icedtea-plugin (click to install) is also available to install if you are going to use OpenJDK 6.

Install it with:

sudo apt-get install icedtea6-plugin

If you really want to use Oracle's Java SE Platform, see How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE?.

  • Under 15.04 the icedtea-7-plugin does not work well with Firefox. I've found that downloading a tar.gz distribution and manually symlinking libnpjp2.so into /usr/lib/firefox-addons/plugins made it work. Note that the websites need to be marked as trusted too in the java control panel (this in turn is only possible if you do not have spaces in the full folder name of the unpacked jre). Jun 29, 2015 at 14:44
  • 5
    OpenJDK is now openjdk-8-jre
    – omikad
    Jun 7, 2016 at 4:49
  • on Ubuntu 16, Firefox 50, with Open-JDK 8... doing apt-get install icedtea-netx followed by apt-get install icedtea-plugin did the trick for me! Thank you for your answer, super helpful! :)
    – Bane
    Feb 2, 2017 at 20:09
  • 3
    Always install the latest version of Open JDK by using sudo apt install default-jdk. Currently this installs version 8. Sep 2, 2017 at 1:54

Installing OpenJDK is not enough for enabling Java in browsers. You'll also need to install the icedtea-7-plugin package:

Install via the software center

A restart of the browser might be required.

  • How is this up to date in 2018? Jan 13, 2018 at 18:49
  • @KonradGajewski Not sure, I have recently not used any Java applets. In fact, Firefox 52 has dropped support for Java plugins and so did Chrome 45.
    – Lekensteyn
    Jan 14, 2018 at 13:34
  • For the past few hours, I was unable to get it running under Firefox, Chromium, or Chrome. I got Java working in Konqueror. Jan 14, 2018 at 20:36

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.

For installing Oracle Java 7:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo mkdir -p /usr/lib/mozilla/plugins #just in case, this will be added to the package in the next version
sudo apt-get install oracle-jdk7-installer
  • After the installation finishes, if you wish to see if it was successful, you can run the following command: java -version (see webupd8.org/2012/01/… )
    – rubo77
    Sep 20, 2014 at 20:28

Installing OpenJDK - Recommended

The simplest way to install Java on Ubuntu is to use OpenJDK. This will work fine for most people. To install it, click on the small button with the Ubuntu logo on it, as shown in the screenshot below.

enter image description here

After opening the Dash Home, you need to type in Terminal. Click on the icon that is circled in the screenshot below.

enter image description here

This will open the Terminal, which is Ubuntu's version the the Windows Command prompt, though the Terminal has many more features. Now, copy and paste the following command into the Terminal window. You will need to use ControlShiftV to paste text into the terminal.

sudo apt-get install -y openjdk-7-jre openjdk-7-jdk

You will need to enter your password to use this command. Although it will not show up in the Terminal, it will still be entered when you type it. After running this command, you will be set up to run and develop Java applications.

Installing Oracle Java

OpenJDK works fine for most people, but if you play Minecraft, you will want to use Oracle Java instead. To install Oracle Java, run the command below one at a time in the Terminal.

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

This will download Java from Oracle's website, and install it for you.

  • 4
    -1 for 3 major reasons: 1 - JDK and JRE alone are not enough to enable java in Web Browsers. You still need icedtea-plugin package (icedtea6-plugin or icedtea7-plugin, the one that matches your java); 2 - JDK already includes the JRE, so no need to install both. Choose either JRE for regular users (like the OP) or JDK for java developers. 3 - Since you had the trouble to post nice screenshots, why suggest the terminal route? Software Center is much more friendly and recommended in this case
    – MestreLion
    Mar 19, 2013 at 2:28
  • webupd8team's PPA has been discontinued. Reference
    – Kulfy
    Apr 19, 2019 at 8:52
  • WARNING: The ppa webupd8team has been DISCONTINUED. Read why here: launchpad.net/~webupd8team/+archive/ubuntu/java
    – Matthew K.
    Dec 5, 2019 at 17:02

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.

Open your terminal with Ctrl+Alt+T and:

Now this will install the latest Java version

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
  • Thanks a lot... but i tried the last sentence "sudo update-alternatives --config java" says "There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-7-oracle/jre/bin/java Nothing to configure." How this is supposed to check if it is in use ???
    – Septrba
    Mar 2, 2013 at 14:35
  • @Septrba You have only "one" Java version installed, only one can be in use, and it's the one you have installed. If you had more than one installed, it would list and show which one is in use. Probably shouldn't have added that to my answer, since it was probably more confusing than helpful. :P Mar 4, 2013 at 20:39

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.

Oracle Java 8 was just released (stable). To install it in Ubuntu, you can use the WebUpd8 Java PPA:

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

The PPA itself doesn't provide Oracle Java 8 binaries (that's not allowed by the Oracle Java license). Instead, an installer is used that automatically downloads and installs Oracle Java 8. Using this PPA, you'll also receive automatic Java 8 updates.

More information and some tips on using / further configuring Oracle Java 8 @ WebUpd8 is in Install Oracle Java 8 In Ubuntu Via PPA Repository [JDK 8].


Unfortunately, because of issues with its license, Oracle Java is no longer distributed within the official Ubuntu repositories. You have two main options: either try OpenJDK -- an open source replacement for Oracle Java -- or proceed with the "manual" installation (which is exactly what you were trying to do). Both these options are described on the help wiki: https://help.ubuntu.com/community/Java. This page also include some other alternatives that, depending on your needs, you may find more suitable.

Just a side note: most of the time, with Ubuntu, you should not download software from the Internet, but rather use the Ubuntu Software Center. The software you'll find there is ensured to be stable, safe and to respect the standard conventions of the system. Oracle Java is just an exception to this rule.


Just go to Aplications --> Ubuntu software center and then search for Java. enter image description here

  • 1
    Your answer would be that the OP installs the previous Java Runtime Environment, and not the latest version jre-6u25-linux-i586.bin
    – scouser73
    Jun 13, 2011 at 14:33
  • 1
    Scouser73, jre-6u25-linux-i586.bin sounds like the proprietary Java implementation from Oracle. This question is about OpenJDK.
    – Lekensteyn
    Jun 13, 2011 at 19:01
  • The one that is marked (in orange) is the open-jdk java6 runtime!
    – Alvar
    Jun 13, 2011 at 19:27
  • scouser73 is referring to a security update of Oracle Java. I don't know if the current version if affected, the installed JRE version is 6b22 but bear in mind that this is unrelated to the version number of Oracle Java, see dbhole.wordpress.com/2011/05/27/…
    – Lekensteyn
    Jun 13, 2011 at 19:33
  • well, Scouser73 had problems with a we page. I only use the jdk and that is all I ever need so I thought it would help.
    – Alvar
    Jun 13, 2011 at 20:38

# current java release - get both jdk / jre download here

sudo mkdir /usr/local/java

cd /usr/local/java

# remove previous installs if any

sudo rm -rf /usr/local/java/jdk*
sudo rm -rf /usr/local/java/jre*

# move downloaded/expanded dirs into /usr/local/java

sudo mv ~/jdk* /usr/local/java/
sudo mv ~/jre* /usr/local/java/

cd /usr/local/java/

# create symbolic links

sudo ln -s jdk*  jdk
sudo ln -s jre*  jre

# ONLY need to do below on fresh ubuntu install - IGNORE if previously installed any java version as its already in place

# setup symlinks :

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jre/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jre/bin/javaws

Finally, put these in your ~/.bashrc

export JAVA_HOME=/usr/local/java/jdk
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JRE_HOME=/usr/local/java/jre
export PATH=$PATH:$HOME/bin:$JRE_HOME/bin

now you're locked and loaded ;-)


UPDATE: Since Ubuntu 16.04 you can install this without the ppa via

$> sudo apt-get update
$> sudo apt-get install openjdk-8-jdk


For Ubuntu < 16.04 there was no official package for Java 8 from OpenJDK ( the open source version ), but you can install it via this PPA by running:

$> sudo add-apt-repository ppa:openjdk-r/ppa
$> sudo apt-get update
$> sudo apt-get install openjdk-8-jdk
  • I just ran the last two commands without the first and it works. So it looks like there's an official package now (2016). Sep 15, 2016 at 10:59
  • Updated the answer for Ubuntu 16.04 Sep 15, 2016 at 14:40

There are a few ways to install Java in Ubuntu:

Install OpenJDK (The open source equivalent to Sun's Java) directly from Ubuntu Software Center. All you need to do is search for Java. That tends to work as is for me.

If you need Sun's Java, say if you want to play Minecraft, you download the JRE as you described from Java.com, but make sure your .bin-file can be executed. You do that by opening a terminal and typing the following (I will assume you have it in your Downloads folder so change the cd line accordingly if that's not where it is):

cd /home/user/Downloads
sudo chmod +x jre-6u31-linux-i586.bin

Then, you should be able to close your terminal, right click on your .bin-file and select "Execute", which should run the installer. If this is not an option, just do the following from terminal (in the same folder as the two other actions):


That simply runs the specified file and if you successfully typed in the two first lines, the installation.


If you are missing Java in Firefox, then

plug=~/.mozilla/plugins/libnpjp2.so && 
test -e $plug && readlink -f $plug || 
  ln -f -s `find ~ -wholename '*jdk*lib*libnpjp2.so' -or -wholename '*jre*lib*libnpjp2.so' | head -n 1` `dirname $plug` && 
ls -la $plug

This script will overwrite libnpjp2.so even if it exists, but points to wrong file (for example, the symlink is broken).

  • 1
    Where should this script be run from (directory location)? Jan 28, 2015 at 22:14
  • from wherever you want, find looks for plugin in ~ and usbdirectories. $plug variable makessure that symlink is put in right directory.
    – test30
    Jan 31, 2015 at 12:46

I made a text-based Java installer using terminal commands. It uses wget, tar, update-alternatives, and ln. It will install the Oracle JRE with the Firefox plugin.

You can download the installer from Google Drive here. Then put it in your home folder, open Terminal and type bash Install. Then it will run the installer in Terminal. It uses sudo, so you will need to type your password after it downloads. Also, this is the 64-bit version, so I will add the 32 bit later.


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.

Detailed instructions to install Oracle Java 8 are updated in the blog here.

You can also use below commands for a quick answer -

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt install oracle-java8-set-default

javac -version

Please do note that you can also install openJDK which is also maintained by Oracle.


By doing sudo apt xxx others are not doing some miricle.

To install the latest version of JDK ( Java Development Kit ) Follow the steps.

  1. Go to Openjdk website https://jdk.java.net/
  2. Download the tar file of latest version right now its 18.
  3. Extract it
  4. Copy it somewhere like /opt directory using mv
  5. Add the path of the bin folder to the PATH, by adding this to your .bashrc
export PATH=$PATH:absolute_Path_of_bin_folder >> ~/.bashrc

and there you have it.

You must log in to answer this question.

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