Monday, July 9, 2012

How to set Java Path in Linux 


PATH=/usr/local/java6/jdk1.6.0_25/bin:$PATH:$HOME/bin:./
export PATH
export JAVA_HOME=/usr/local/java6/jdk1.6.0_25
export CLASSPATH=/usr/local/java6/jdk1.6.0_25/lib/tools.jar:/usr/local/java/jdk1.6.0_25/jre/lib/rt.jar:./



1) Download latest version of Java
2) goto ur Dowload directory n give ls -l for check ur download jdk-1.6.0_14.bin
3) chmod +x jdk-1.6.0_14.bin ( change execute permission for ur jdk)
4) after finish execute permission give this commade
./jdk-1.6.0_14.bin
5) read the java License a
6) after finish step 5 create one Directory (/usr/Java/) mkdir /usr/Java
7) move ur Extract jdk-1.6.0_14 to /usr/Java (mv jdk-1.6.0_14 /usr/Java/)



Set Environment Variable
-------------------------

create one text file name like java.sh using vi editor
copy below line in java.sh file

 #!/bin/bash

   #PATH=/usr/java/jdk1.6.0_20/bin:$PATH:$HOME/bin:./:/usr/java/ant
   export PATH
   #export  ANT_HOME=/usr/java/ant
   export JAVA_HOME=/usr/java/jdk1.6.0_20
   export CLASSPATH=/usr/java/jdk1.6.0_20/lib/tools.jar:/usr/java/jdk1.6.0_20/jre/lib/rt.jar:./
   PATH=/usr/java/jdk1.6.0_20/bin:$PATH:$HOME/bin:$ANT_HOME/bin:./
   #export OPENOFFICE_PATH=/usr/lib/openoffice.org/program

change ur jdk installation path


after finish mv java.sh to /etc/profile.d (mv java.sh /etc/profile.d)

once u copeid java.sh /etc/profile.d

run this command source /etc/profile.d/java.sh

to check ur installtion give this
echo $JAVA_HOME

-------------------

change default Java path
------------------------

1) update-alternatives --config java (for check default jdk path)\
2) update-alternatives --install /usr/bin/java java /usr/local/java7/jdk1.7.0_04/bin/java 20000





No comments:

Post a Comment