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

Tomcat 7 from repository and Debian Wheezy.

If I try to start Tomcat by service it does not work

service tomcat7 start
[FAIL] no JDK found - please set JAVA_HOME ... failed!

But the variable is there

/var/lib/tomcat7/conf# echo $JAVA_HOME

If I try from init.d it does work

/etc/init.d/tomcat7 start
[ ok ] Starting Tomcat servlet engine: tomcat7.

Looking in the /etc/inittab

# The default runlevel.

The default seems to be the 2

So, looking in the /etc/rc2.d

lrwxrwxrwx 1 root root  17 Nov 18 22:50 S01tomcat7 -> ../init.d/tomcat7

It seems it refers always to the same /etc/init.d/tomcat7 and I do not understand why it fails (complaining about java)..

share|improve this question
up vote 3 down vote accepted

When you run an init script directly, your shell's environment is used. When you run the service command, it is not. You should set JAVA_HOME in /etc/default/tomcat7.

share|improve this answer

You need to create an environment variable called JAVA_HOME with the value of the directory path of your Java installation.

If you are doing deployment use the jre path, if you need access to the development tools use the jdk path.

share|improve this answer
The variable is there, I modified the question – elect Jan 5 '14 at 15:46
I'm guessing there is a subdir called jdk and/or jre. Try extending the path to include the jdk or jre subdir. – ErikE Jan 5 '14 at 15:58

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.