Ubuntu has Open JDK packages which you can simply install them for your Java Development Kit for developing Java-based applications. If you type ‘java’ or ‘javac’ in a terminal window without any JDK / JRE installed in the system, it will tell you a list of packages where you can find the java program as follow:
$ javac The program 'javac' can be found in the following packages: * openjdk-6-jdk * ecj * gcj-4.4-jdk * gcj-4.6-jdk * gcj-4.5-jdk * openjdk-7-jdk Try: sudo apt-get install
From the above message, you can install OpenJDK 7 on Ubuntu by simply issuing ‘sudo apt-get install openjdk-7-jdk’ in the terminal window. The script will retrieve OpenJDK package and its dependencies on given repository servers.
This tutorial is not showing you on how to install OpenJDK 7 on Ubuntu, instead it will show you how to install Oracle Java SE 7 (JDK 1.7) on Ubuntu 11.10 ‘Oneiric Ocelot’. And is are the step-by-step:
1. Download the Java SE 7 (JDK 1.7) from http://www.oracle.com/technetwork/java/index.html. At the time of this writing, the version of Java SE is Java SE 7 Update 2 (Java SE 7u2).
2. Once it’s downloaded, extract it and move it to a system folder (You can move it to /usr/local, /opt or any other folders you would prefer to)
$ tar zxf jdk-7u2-linux-i586.tar.gz $ sudo mv jdk1.7.0_02 /opt/
3. Create a symbolic link of jdk1.7.0_02 folder to java.
$ cd /opt/ $ sudo ln -s jdk1.7.0_02 java
4. Add the ‘/opt/java/bin’ folder into the system PATH
$ export PATH=$PATH:/opt/java/bin
To make the Java path set at boot, you need to update the /etc/profile or .profile (in you $HOME folder) to include /opt/java/bin in the PATH.
5. Done. The Java SE 7 has been successfully installed. Type ‘java -version’ in terminal window to verify it.
$ java -version java version "1.7.0_02" Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) Server VM (build 22.0-b10, mixed mode)
I hope this tutorial will be useful for everyone who want to install Java SE 7 on Ubuntu 11.10 ‘Oneiric Ocelot’.