Thursday, September 9, 2010

Configuring Java environment in Linux

After installing Java Development Kit(JDK) or Java Runtime Environment(JRE) on Linux, you have to configure java for running or compiling java programs.
JDK is usually installed into /usr/java directory
now open the terminal
now open the bashrc file which is present in /etc directory by using 
command vi bashrc 
[subin@wipro-049cafd91 jet7.0-pro]$ cd ..
[subin@wipro-049cafd91 ~]$ pwd
/home/subin[subin@wipro-049cafd91 ~]$ cd /
[subin@wipro-049cafd91 /]$ pwd
/
[subin@wipro-049cafd91 /]$ cd /etc
[subin@wipro-049cafd91 etc]$ pwd
/etc
[subin@wipro-049cafd91 etc]$ vi bashrc

To edit the bashrc file to configure java, press "Insert" button in keyboard

export JAVA_HOME=/usr/java/jdk1.6.0_14
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
export CLASSPATH=/usr/java/jdk1.6.0_14/lib/tools.jar: \ /usr/java/jdk1.6.0_14/lib/dt.jar

Once you have edited your .bashrc file
press "escape" button in keyboard
and type ":wq!" and press enter
you can see

[subin@wipro-049cafd91 etc]$ 

Execute the following command to make the bash shell to re-read the contents of the .bashrc file 
[subin@wipro-049cafd91 etc]$ source ~/.bashrc

Now you can compile and execute Java programs in Linux.

No comments:

Post a Comment