0

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

cherouvim
  • 794
  • 3
  • 21
  • 37

1 Answers1

1

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.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52