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.

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
/usr/lib/jvm/java-7-oracle

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.
id:2:initdefault:

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

2 Answers 2

up vote 2 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 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 at 15:58

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.