I want to install Oracle's JRE and to update to the latest version with the Software Updater when they released. Is there a Ubuntu package that is provided by Canonical or Oracle?
Before release Java 7, I followed this way to install Java 6.
But it doesn't work for Java 7. There is no package sun-java7-xxx
. How can you install Java 7?
Best Answer
There is a similar answer on how to install JRE 7.
Install Java JDK
The manual way
Download the 32-bit or 64-bit Linux "compressed binary file" - it has a ".tar.gz" file extension.
Uncompress it
tar -xvf jdk-8-linux-i586.tar.gz
(32-bit)tar -xvf jdk-8-linux-x64.tar.gz
(64-bit)The JDK 8 package is extracted into
./jdk1.8.0
directory. N.B.: Check carefully this folder name since Oracle seem to change this occasionally with each update.Now move the JDK 8 directory to
/usr/lib
Now run
This will assign Oracle JDK a priority of 1, which means that installing other JDKs will replace it as the default. Be sure to use a higher priority if you want Oracle JDK to remain the default.
Correct the file ownership and the permissions of the executables:
N.B.: Remember - Java JDK has many more executables that you can similarly install as above.
java
,javac
,javaws
are probably the most frequently required. This answer lists the other executables available.Run
You will see output similar to the one below - choose the number of jdk1.8.0 - for example
3
in this list (unless you have have never installed Java installed in your computer in which case a sentence saying "There is nothing to configure" will appear):Repeat the above for:
Note for NetBeans users!
You need to set the new JDK as default editing the configuration file.
If you want to enable the Mozilla Firefox plugin:
N.B.: You can link the plugin (
libnpjp2.so
) to/usr/lib/firefox/plugins/
for a system-wide installation (/usr/lib/firefox-addons/plugins
from 15.04 onwards). For Ubuntu 13.10, the path to the plugin directory is/usr/lib/firefox/browser/plugins/
.Depending on your configuration, you might need to update the apparmor profile for Firefox (or other browsers) in
/etc/apparmor.d/abstractions/ubuntu-browsers.d/java
:Then restart apparmor:
The easy way (Obsolete)
The easiest way to install the JDK 7 is to do it with the Web Up8 Oracle Java OOS. However, it is believed that this PPA is sometimes out of date. Also note the dangers of using a PPA.
This installs JDK 7 (which includes Java JDK, JRE and the Java browser plugin):
Source
N.B.: Before someone screams this is against the Oracle redistribution license - the PPA does not actually have Java in the personal repository. Instead, the PPA directly downloads from Oracle and installs it.
The Script way
If you're on a fresh installation of Ubuntu with no previous Java installations, this script automates the process outlined above if you don't want to type all that into a console. Remember, you still need to download Java from Oracle's website -- Oracle's links are not
wget
friendly.Before using this make sure that this script is in the same directory as the
.tar.gz
file extension that you downloaded and there are no files that start with jdk-7 in the same folder. If there are, please move them out of the folder temporarily. Remember to make the script executable (chmod +x <script's file>
).If you want to install the plugin for Firefox then add this to the end of the script:
Check if installation was successful
You can check if the installation succeeded with the following command:
You should see something like
You can check if the JRE Mozilla plugin has been successful by using the official oracle website.
For Java 6: How do I install Oracle JDK 6?