Ubuntu 13.04 comes shipped with Open Jdk 7. For couple of reasons you might want to use the Oracle Java 7. This post guides you through the process.
1. Check current java version: Just check current version of installed java before we start
$ java -version
2. Download oracle java jdk. Java can be installed from this location. Download Oracle Java.
3. Create /usr/lib/jvm. This is the location where we are going to put our java.
$ sudo mkdir -p /usr/lib/jvm
Note: -p option just ensures that whole path is created
4. Extract downloaded files to our created directory /usr/lib/jvm. Picking tar archive file from Downloads folder and extracting to our /usr/lib/jvm directory. Note ‘jdk-7u25-linux-x64.tar.gz’ is the name of my downloaded file. Your archive filename may vary with the version downloaded.
$ sudo tar xvf ~/Downloads/jdk-7u25-linux-x64.tar.gz -C /usr/lib/jvm
5. Tell ubuntu where our java is present
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_25/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_25/bin/java" 1
6. Set Oracle java as our default java
$ sudo update-alternatives --set "javac" "/usr/lib/jvm/jdk1.7.0_25/bin/javac"
$ sudo update-alternatives --set "java" "/usr/lib/jvm/jdk1.7.0_25/bin/java"
7. Update system class patths
$ sudo nano /etc/profile
Add the below lines to the profile:
Reload the profiles
$ . /etc/profile
8. We are done. Check the java version to verify