How to install java jdk on ubuntu (linux)

How to install java jdk on Ubuntu? here I provide few steps to demonstrate how it works.

Installation Setup

1) Issue following command to find out current jdk version in apt-get

apt-cache search jdk

2) Install java JDK and JRE with apt-get install

apt-get install sun-java6-jdk sun-java6-jre

3) Ubuntu will auto download necessary file from web for installation.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gsfonts-x11 java-common odbcinst1debian1 sun-java6-bin unixodbc
Suggested packages:
  equivs sun-java6-demo openjdk-6-doc sun-java6-source sun-java6-plugin ia32-sun-java6-plugin sun-java6-fonts ttf-kochi-gothic ttf-sazanami-gothic
  ttf-kochi-mincho ttf-sazanami-mincho ttf-arphic-uming libmyodbc odbc-postgresql libct1
The following NEW packages will be installed:
  gsfonts-x11 java-common odbcinst1debian1 sun-java6-bin sun-java6-jdk sun-java6-jre unixodbc
0 upgraded, 7 newly installed, 0 to remove and 335 not upgraded.
Need to get 57.1MB of archives.
After this operation, 168MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://in.archive.ubuntu.com karmic/main java-common 0.30ubuntu5 [80.3kB]
Get:2 http://in.archive.ubuntu.com karmic-updates/multiverse sun-java6-jre 6.24-1build0.9.10.1 [6,386kB]                                                    
0% [2 sun-java6-jre 27656/6,386kB 0%]                           

4) After installation done, jdk and jre will install at /usr/lib/jvm/java-6-sun-1.6.0.06

5) Ubuntu help to create a java symbolic link and put in /usr/bin for shortcut access

4) type java -version, DONE !!

Post-Installation Setup

Set JAVA_HOME into environment variable

Copy following statement and append to /etc/profile or .bashrc file, make system set JAVA_HOME into system environment variable.

export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.06"

Leave a comment