In this example, we will show you how to install JDK 7 on Ubuntu 12.

P.S This article is updated on 6/12/2012.

1. Find Openjdk

Ubuntu is using OpenJDK, in terminal, issue this command opt-cache search openjdk to search all the available Openjdk version.

$ apt-cache search openjdk
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
icedtea-7-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
icedtea-7-plugin - web browser plugin based on OpenJDK and IcedTea to execute Java applets
openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk - OpenJDK Development Kit (JDK)
openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-7-source - OpenJDK Development Kit (JDK) source files
java-package - Utility for creating Java Debian packages
freemind - Java Program for creating and viewing Mindmaps

2. Install Openjdk

Issue command apt-get install openjdk-7-jdk to install JDK7. Ubuntu will auto download JDK and start the installation, wait a few minutes for the downloading process.

$sudo apt-get install openjdk-7-jdk

3. Verification

Ubuntu installs JDK at /usr/lib/jvm/jdk-folder, for example /usr/lib/jvm/java-7-openjdk-amd64/. In additional, Ubuntu also puts the JDK bin folder in the system path, via symbolic link. For example, /usr/bin/java.

To verify if JDK is installed properly, type java -version.

$java-version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
mkyong@yong-ubuntu:/usr/lib/jvm/java-7-openjdk-amd64/bin$

4. Post-Installation Setup

This step is optional. To configured JAVA_HOME in system path each time the terminal is started, you can append the export JAVA_HOME to /etc/profile or .bashrc.

echo $JAVA_HOME
//show nothing
 
$sudo echo "export JAVA_HOME=\"/usr/lib/jvm/java-7-openjdk-amd64/\"" >> ~/.bashrc
//restart terminal
 
echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/

Done.

Tags :
Founder of Mkyong.com, love Java and open source stuffs. Follow him on Twitter, or befriend him on Facebook or Google Plus.
Here are some of my recommended Books

Related Posts

Popular Posts