If I downloaded the latest JDK from Oracle. Do I just download the
.tar file, and extract it at
There is a similar question on how to install JRE 7.
Install the JDK
JDK 7 package is extracted into ./jdk.1.7.0_02 directory. N.B. check carefully this folder name since Oracle seem to change this occasionally with each update.
sudo mkdir -p /usr/lib/jvm sudo mv ./jdk.1.7.0_02 /usr/lib/jvm/jdk1.7.0
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
sudo chmod a+x /usr/bin/java sudo chmod a+x /usr/bin/javac sudo chmod a+x /usr/bin/javaws sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
N.B. remember - Java JDK has many more executables that you can similarly install as above.
This answer lists the other executables available.
sudo update-alternatives --config java
You will see output similar one below - choose the number of jdk1.7.0 - for example
Check the version of you new JDK 7 installation:
Repeat the above for:
Enable mozilla firefox plugin:
N.B. you can link the plugin (
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:
Confirm that the JRE has been successful by using the official oracle website.
For Java 6:
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, either by doing
If you want to install the plugin for Firefox then add this to the end of the script
Confirm if Java has been properly installed.
Confirm that the JRE Mozilla plugin has been successful by using the official oracle website.
The link has instructions for installing Oracle JDK, the Java 7 browser plugin and how to revert the changes.
So here is a tested (under Ubuntu 11.04 and 11.10) 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:
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.
I wrote a blog post with a very detailed explanation on how to install Java 7 on Natty, both OpenJDK's and Sun's:
OpenJDK is installed from the PPA provided by Damien Lecan, and Sun's is installed manually. As far as know, until now that is the only guide that is correct both in the steps and the explanation.
If you find any problems, post a comment there and I will try to fix it.
Get the JDK from Oracle/Sun, download the Java JDK at:
Pls download or move the downloaded file to your homeDirectory ~ for ease.
Run in a terminal..
Now enable Java (by running individually) :
Close all browsers.
Create a Mozilla plugins folder in your home directory :
Create a symbolic link to your Mozilla plugins folder. For 64-bit systems, replace ‘i386’ with ‘amd64’:
Verify JRE at http://java.com/en/download/installed.jsp
I propose one way to make easier the installation of Oracle's Java 7.
Since Ubuntu does not provides the Oracle's Java 7 packages, I'm providing a collection of Ubuntu packages on my own package repository.
The packages are fully integrated in the Ubuntu way to support Java. You will be able to select the Oracle's Java 7 alternative with the standard tools: update-alternative or update-java-alternative.
The main page of my contribution is: http://www.arakhne.org/jdk/index.html
To obtain the packages, you only need to add my package repository into your system configuration. The process is explained in http://www.arakhne.org/ubuntu.html
The easiest way is just downloading java 7 with Netbeans here - http://www.oracle.com/technetwork/java/javase/downloads/jdk-7-netbeans-download-432126.html
Here's a bash script that could help in setting up the java alternatives:
Rather than downloading the
where I believe the current
The first will install alien, a application for converting
This package may then be installed by running:
This is how I successfully installed it on my machine.