Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a /etc/init.d/tomcat1 script which runs on boot on rc levels 3 and 5. This script calls /usr/local/tomcat1/bin/startup.sh on start.

Although I can manually execute /usr/local/tomcat1/bin/startup.sh from console, on boot I get the following in /var/log/boot.msg:

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

After that I added the following in /etc/init.d/boot.local:

export JAVA_HOME="/usr/local/java"

But I still get the same message about JAVA_HOME missing.

What I ended up doing is modifying /usr/local/tomcat1/bin/catalina.sh and hardcoding the following:

JAVA_HOME="/usr/local/java"

Tomcat now does start on boot but I know that hardcoding this in the catalina.sh script is not good.

So the question is, how can I set/export JAVA_HOME so that it's readable from scripts running on boot?

thanks

share|improve this question
1  
Did you set JAVA_HOME in /etc/profile? –  quanta Aug 29 '11 at 8:21
    
Why did you put it everywhere but not in /usr/local/tomcat1/bin/startup.sh?! –  mailq Aug 29 '11 at 8:38
add comment

1 Answer

Put your changes in /etc/profile.local so they load for all users. In this case, putting JAVA_HOME=/usr/local/java in that file should be sufficient.

/etc/boot.local runs after all other scripts for a given runlevel, so changes you make there won't be seen by other init scripts. For your example above to work, you would need to put the following in boot.local:

export JAVA_HOME=/usr/local/java
/usr/local/tomcat1/bin/startup.sh

i.e. set the environment variable, then launch the startup script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.