Installing JDK in LINUX Environment

A. If you want to install using apt-get.

Step 1: make sure that you are connected with internet, then open the command prompt and follow the steps
Step 2: type the following command and press enter run
$ sudo apt-get update (to update the repository)
$ sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts
Step 3: installation will immediately start, Follow the steps, you can move using TAB key for selecting the options.
Step 4: Now set JAVA_HOME and PATH params in .bashrc file.
first locate the jdk installation directory using locate command, generally jdk is installed at /usr/lib/jvm.
you can find a shoft link java-6-sun within /usr/lib/jvm pointing to jdk directory.
open ~/.bashrc by following command in gedit
$gedit ~/.bashrc
in the .bashrc file scroll down after the last line written and then type the following
export JAVA_HOME=/usr/lib/jvm/java-6-sun   #this sets the JAVA_HOME parameter for the environment
and will be used by other applications to find JAVA in your system (such as apache tomcat for example)
export PATH=$PATH:$JAVA_HOME/bin   #this will append java bin path to your existing path parameter
Step 5: you are done, exit terminal, reopen terminal, type a java program and compile with javac and run with java.

B . If you want install jdk from a downloaded bin file

Step: 1  ->   download sun java JDK bin file “jdk-6u18-linux-i586.bin” or the latest version from
Step: 2  ->   create a directory under your Home/USER directory with name jvm , For  Example My
user directory is /home/saikat and I have created a directory jvm under /home/saikat that is jvm is
under ~ (~ symbol in linux indicates the user home directory, that is ~ is equivalent of saying /home/saikat in my

Step: 3  -> copy jdk-6u18-linux-i586.bin to ~/jvm directory.
Step: 4  -> open the terminal, in gnome one can find the terminal link at Application ->Accessories -> Terminal.
Step: 5  -> go inside ~/jvm by using cd command.
that is from $ prompt type:  cd ~/jvm
.bin files are self extractor executable, they need to be executed with ./ command.
So in order to start the installation process type the followinf command from the $ prompt (from within ~/jvm directory)
./jdk-6u18-linux-i586.bin     (if you have different version bin file then write your .bin file name)

Immediately installation proceedure will start, scroll down till u find “More” written at the bottom and until u get the
following message

Please enter “yes” or “no”.
Do you agree to the above license terms? [yes or no]
type “yes” and press enter and then extraction will start immediately and it will complete the extraction and installation
Step 6:   -> After the above process you can find a directory named jdk1.6.0_18 under ~/jvm, all the required JDK files are inflated
under jdk1.6.0_18.
Step 7:   -> Now create a soft link of jdk1.6.0_18 directory by the following command
$ln -s jdk1.6.0_18 java-6-sun  (java-6-sun is the name of your softlink (in windows terminology a softlink is just
equivalent of a short-cut) )
Step 8:   -> Now set the PATH parameter of your environment.
for that type the following from your $ prompt.
$ gedit   ~/.bashrc
(gedit is a text based editor for gnome, you can edit text files in gedit, windows equivalent of gedit is wordpad.)
you will find gedit window appearing with .bashrc file, this is your profile file.
scroll down to the end of the file and append the following line:
export JAVA_HOME=~/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

please dont do anyother thing in .bashrc (unless u understand what u r doing).
click save and exit from gedit.
Step 9: exit from terminal typing exit. Reopen terminal and write a java program and compile with javac and run with java. You are


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s