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.
OpenJRE
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
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.
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
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.
After opening the Dash Home, you need to type in Terminal. Click on the icon that is circled in the screenshot below.
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.
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.
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.
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:
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.
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.
There are several implementations of Java. The three most common implementations when talking about it for Ubuntu are:
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.
OpenJRE
By opening a terminal and typing
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 thedefault-jdk
package:Also important is to install the wrapper for supporting Java applications on your web browser, the Iced-Tea Java Plugin.
IcedTea Plugin
Or via a terminal
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:
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
Or if you need the developers' package,
openjdk-6-jdk
(click to install), install it with: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:
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?.
Installing OpenJDK is not enough for enabling Java in browsers. You'll also need to install the
icedtea-7-plugin
package:A restart of the browser might be required.
For installing Oracle Java 7:
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.
After opening the Dash Home, you need to type in Terminal. Click on the icon that is circled in the screenshot below.
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.
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.
This will download Java from Oracle's website, and install it for you.
Open your terminal with Ctrl+Alt+T and:
Now this will install the latest Java version
Oracle Java 8 was just released (stable). To install it in Ubuntu, you can use the WebUpd8 Java PPA:
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
.# current java release - get both jdk / jre download here
# remove previous installs if any
# move downloaded/expanded dirs into /usr/local/java
# create symbolic links
# ONLY need to do below on fresh ubuntu install - IGNORE if previously installed any java version as its already in place
# setup symlinks :
Finally, put these in your ~/.bashrc
now you're locked and loaded ;-)
UPDATE: Since Ubuntu 16.04 you can install this without the ppa via
LEGACY ANSWER:
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: