Most of the time many  people choose  to install Java sdk in /usr/java   directory.   After installing Tomact ( asking  jakarta  tomact ? or apache tomcat ?…. I think both are same   apache is group of projects and jakarta  is one of those projects name) , We may need to set the path of java home directory other wise tomcat will not start , it just shows the error messgae “The JAVA_HOME environment variable is not defined”.

[root@centcmd bin]# ./startup.sh
The JAVA_HOME environment variable is not defined
This environment variable is needed to run this program

Here is how i set the environment varaible for java home…

To set the java home directory  type the command from terminal

export JAVA_HOME=”/path/to/java/home”

in my case it is….

[root@centcmd bin]# export JAVA_HOME=”/usr/java/jdk1.6.0_26″

to set the path of java commands

export PATH=”/path/to/java/bin:$PATH” 

in my case it is ….

[root@centcmd bin]# export PATH=”/usr/java/jdk1.6.0_26/bin:$PATH” 

After setting up java path just run the command  [root@centcmd bin]# cat ~/ .bash_profile

which should display the  entries of JAVA PATH.

If we need to set java home and path , we need to edit /etc/profile.d

without opening profile.d in editors like vi , we can just type these commands directly on terminal

 

to set Java home

 

[root@centcmd bin]#echo ‘export JAVA_HOME=/usr/java/jdk1.6.0_26’>/etc/profile.d/jdk.sh

[root@centcmd bin]#echo ‘export PATH=$JAVA_HOME/bin:$PATH’>>/etc/profile.d/jdk.sh

 

now we need to set the source file for java

 

[root@centcmd bin]#source /etc/profile.d/jdk.sh

 

now java home has been set for all the users .


now if you type the command  java -version   it should show the version of your java  .

 




 


0 Comments

Leave a Reply

Your email address will not be published.