Thursday, November 12, 2009

How to Install Java on Linux

In this tutorial will discuss about the installation of Java Development Kits (JDK) on Linux Ubuntu 9.04 with the manual, which is unpack the installer to do it. Here are the steps:

  • Download the latest JDK package from http://java.sun.com
  • Copy the JDK package to your Home Folder. We assume the file name: jdk-6u16-linux-i586.bin
  • Sign terminal and login as super user
paiman@salafy: ~ $ sudo su
password:
  • Do unpack the file to the JDK
sh jdk-6u16-linux-i586.bin
  • License agrément will appear, type 'yes'
  • The process of unpacking will take place and when completed it will create a directory '/ usr/java/jdk1.6.0_16'. We call this directory as the value of the variable JAVA_HOME.
  • Up to here JDK already installed and you can install your favorite Java IDE, like NetBeans or Eclipse.
  • But if you want to be able to compile through terminal, you have to set CLASSPATH first.
  • The trick is to define the value of the variable JAVA_HOME and PATH:
export JAVA_HOME = / usr/java/jdk1.6.0_16
export PATH = $ JAVA_HOME / bin: $ PATH

  • To check if the value of the two variables have been updated, do this:
echo $ JAVA_HOME
echo $ PATH
If both displays output, then the two variables defining the success

  • Up to here CLASSPATH has been set and you are able to compile through terminal. To test it do:
javac
java-version
  • But the problem is, when you close the terminal then you have to go back CLASSPATH settings. This certainly was not wearing. So, you need to update the file. Bashrc to add information about your CLASSPATH to be set
  • Open the file. Bashrc:
~ /. bashrc
if there is a message 'permission denied', then write it: nano ~ /. bashrc
  • At the end of the file to add information about the CLASSPATH and save:
JAVA_HOME = / usr/java/jdk1.6.0_16
PATH = $ JAVA_HOME / bin: $ PATH
  • And now, you can directly compile java file through the terminal.

0 comments: