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?
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?
There is a similar answer on how to install JDK 8
Install the JRE
Download the 32-bit or 64-bit Linux "compressed binary file" - it has a ".tar.gz" file extension and uncompress it
The JRE 7 package is extracted into ./jre1.7.0 directory. Now move the JRE 7 directory to
/usr/lib
:Afterwards, run the following to get a list of currently installed Java alternatives.
You will get output as:
Remember the last number and press enter to exit this utility i.e. in this example remember the number
2
.If only one alternative is shown then remember the number
0
.This will add your new JRE 7 installation into the alternatives list i.e. use the remembered number + 1, that is, 3 in the example above. Now configure Java to use the Oracle Java JRE:
You will see output similar one below - choose the number of jre1.7.0, that is,
3
:N.B.: If there was no previous Java installation then the new JRE will be the default and you will not see the above.
Check the version of you new JRE 7 installation:
It should produce
Install the Firefox/Chrome plugin
In a terminal:
Remove the IcedTea plugin, if it has been installed.
Remove a former version of the Java plugin (may or may not be present):
Now you can install the plugin, by creating a symbolic link (you tell Firefox, where the plugin is located). For 32-bit Java use
For 64-bit Java use
Confirm that the JRE has been successful by using the official oracle website.
Here is a tested and working solution for installing Oracle JDK 7 and all its files so "javac" and everything else works: How To Install Oracle Java 7 (JDK) In Ubuntu
Here are the commands (just for convenience):
After a few minutes, Oracle Java JDK should be successfully installed on your Ubuntu machine. You can check out the version by running these commands in a terminal:
Update Oracle has released Java 8 (stable). To install it, use the following commands:
More information @ WebUpd8: Install Oracle Java 8 In Ubuntu Via PPA Repository [JDK8]
From http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html :
This is how I installed it in Oneiric just now. It will be a rather lengthy answer, but it worked for me.
Download latest Java SDK 1.7.0 from Oracle. Then extract it to /usr/lib/jvm:
After that I created .java-1.7.0-oracle.jinfo file in /usr/lib/jvm with the following contents:
Then you need to tell update-alternatives about all the new stuff:
Now you can use update-alternatives to select newly installed Java SDK.
This worked for me, if there is a more elegant way (without using third-party PPAs) I'd be glad to hear about it. I still need to test Firefox if I can run Java in it.
An updated answer:
I suggest using one of the installers from the webupd8team ppa in this way:
Enter these 2 commands in the Terminal to add this PPA and update your packages list:
Enter one (or more) of these commands to install the proprietary Java(s) you require:
When the respective Java installer script is loaded and then it downloads and installs the proprietary Java packages, you can also enter the following command to check the result of the installation:
You should then get a terminal output (for java8 stable version) like this:
Further info: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
NB: These packages provide Oracle Java JDK, which includes Java JDK, JRE and the Java browser plugin. And the webupd8team/java PPA contains only these installers, which simply connect to Oracle Java download site and install the latest JDK.
I appreciate all the previous answers. I want to add this answer to simplify things which is done by www.webupd8.org to make installation in 2-5 minutes.
This installation includes:
That's all!! Now to check the Java version
The output will be like
There may come a new version, and then you can simply update it with this command:
Setting up environment variables
For more, check out Install Oracle Java 7 in Ubuntu via PPA Repository.
This solution will give you clean built packages just as they used to ship with Ubuntu before Oracle came around.
The answer
First the answer, then the explanation. Open a terminal and copy and paste the following, line by line.
This will build the official sun-java6-* packages and make them available in the software-center. If you also want oracle-java7-* packages, run the script like this:
Now you can install the packages with your preferred package manager.
The explanation
When Oracle changed the distribution license for Java, Linux distributions weren't allowed to update the official packages anymore. Github user rraptorr took the Debian script that was used to build the packages until then, and modified it to work with the updated downloads from Oracle. He now provides packging scripts for SUN Java6 and Oracle Java7.
The oab.java.sh script is just a wrapper that automatically downloads the current version, creates the packages and adds them to a local repository.
Further notes
Packages created and installed using this method, will not receive updates automatically - only when you rerun the script. You can circumvent this by creating a cronjob that runs this script on a regular basis. The savest way to do this is using anacron by putting the script in /etc/cron.daily.
Now your official Java packages will always be up-to-date.
This worked for my development needs of being able to run/compile 1.6 or 1.7. Previously I was just running 1.6 from a Ubuntu apt package.
Update JAVA_HOME and PATH in bash file
On AMD64 you need modify a little the command to create the symbolic link:
only change the
i386
toamd64
.