Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/ on start.

Although I can manually execute /usr/local/tomcat1/bin/ 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/ and hardcoding the following:


Tomcat now does start on boot but I know that hardcoding this in the 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?


share|improve this question
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/! – mailq Aug 29 '11 at 8:38

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

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

share|improve this answer

Your Answer


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.