Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Arch Linux. Servlet apparently had compatibility problems with openjdk so I uninstalled it and installed the plain jdk/jre from AUR.

# /etc/rc.d/tomcat7 restart
:: Stopping tomcat7 daemon [FAIL] 
:: Starting tomcat7 daemon [BUSY]
Cannot locate Java Home

Added export TOMCAT_JAVA_HOME=/opt/java to /etc/profile.d/ (and equivalent under jdk.csh), rebooted. echo $JAVA_HOME and echo $TOMCAT_JAVA_HOME both return /opt/java, but still no dice. Why?

share|improve this question
up vote 1 down vote accepted

I solved this issue following this page:

Basically you have to add these lines in your /etc/rc.d/tomcat7 file, below the line ". /etc/conf.d/${daemon_name}"

# The JAVA_HOME of the JVM for Tomcat to use

if [ -x /usr/lib/jvm/java-6-openjdk ]; then
elif [ -x /opt/java/ ]; then

# Tomcat additional commandline options

Hope this helps.

share|improve this answer
That did it. Thank you. – Hugh Guiney Jan 8 '12 at 4:13

You need to try doing :

sudo env

root mustn't be allowed to see environment the way "we" do.

The Sudoers Manual has this to say...

Since environment variables can influence program behavior, sudoers provides a means to restrict which variables from the user's environment are inherited by the command to be run.

... and ...

By default, the env_reset option is enabled. This causes commands to be executed with a minimal environment containing the TERM, PATH, HOME, MAIL, SHELL, LOGNAME, USER, USERNAME and SUDO_ variables in addition to variables from the invoking process permitted by the env_check and env_keep options.

My solution was :

# Create a sudoers extension file and authorize passing JAVA_HOME, M2_HOME, etc into new environment
cd ~/
rm -f neededBy*
echo 'Defaults env_keep+="JAVA_HOME M2_HOME CATALINA_HOME TOMCAT_USER"' > neededByTomCat
chmod 0440 neededByTomCat
sudo cp neededByTomCat /etc/sudoers.d/

I hope this helps,


share|improve this answer
I was already root; no sudoing involved. Tried your solution anyway though; didn't work. – Hugh Guiney Dec 27 '11 at 23:28

Do you get anything by typing "javac" in the console? That will tell you if you have JDK installed rather than just JRE. Also, type the command "which java" to see where your java is linked to. I never use ArchLinux, but on Ubuntu and Mint, they use the alternatives link system to link the default Java installation... in that case I use a tool called "galternatives" to configure Oracle Java after I install it.

I don't think Arch Linux uses the alternatives system like Ubuntu does, but it seems like adding java to the PATH environment variable, in your .bashrc , would be the way to go, rather than unnecessarily editing the JAVA_HOME and CATALINA_HOME env variables in the tomcat script (since the script should be able to auto-determine those based on the java binaries location).

share|improve this answer
javac exists, yeah. As I said I installed the JDK from AUR (community repo). which java is /opt/java/bin/java. No alternatives system on Arch. Anyway, Java is already in my PATH. Haven't edited any existing variables; only added a new one (TOMCAT_JAVA_HOME). – Hugh Guiney Dec 27 '11 at 23:39
@Hugh Guiney - what happens when you try robregonm's answer? Also, when you set your var do you also export it? This shouldn't be this hard of an issue and you have given us limited information. Can you possibly post your start script or is it too long? – djangofan Jan 5 '12 at 19:21

Open and add the following lines before the first code lines (but ofc below the shebang)


Adjust the path to fit your needs. No need to manipulate any PATH or persistent variable for Tomcat to work properly.

share|improve this answer
Tried this. Didn't work. – Hugh Guiney Dec 28 '11 at 18:29

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.