I'm trying to get Tomcat7 running on a Raspberry Pi B+. I get an error message saying that JAVA_HOME is not set. I guess that if I set it in Bash, it won't load on startup, or am I wrong there?

sudo apt-get install tomcat7
[FAIL] no JDK found - please set JAVA_HOME ... failed!
invoke-rc.d: initscript tomcat7, action "start" failed.

JDK is installed:

ls -al /usr/lib/jvm/
total 32
drwxr-xr-x  4 root root  4096 mrt 13 14:23 .
drwxr-xr-x 72 root root 12288 mrt 13 14:19 ..
drwxr-xr-x  9 root root  4096 mrt 13 14:23 jdk-7-oracle-armhf
-rw-r--r--  1 root root  1917 sep 25  2013 .jdk-7-oracle-armhf.jinfo
drwxr-xr-x  9 root root  4096 feb 16 13:31 jdk-8-oracle-arm-vfp-hflt
-rw-r--r--  1 root root  2155 mrt 22  2014 .jdk-8-oracle-arm-vfp-hflt.jinfo

I;ve created the file /etc/profile.d/jdk_home

export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/

After a restart this doesn't change anything.

How can I get this working?

  • 2
    If you're using the default graphical login (lightdm), /etc/profile and other bash login shell scripts never get sourced, because you never actually start a login shell (different DM's have different policies about this...). Try /etc/environment instead (there's probably nothing in it currently).
    – goldilocks
    Mar 13, 2015 at 16:00
  • I use the commandline only right now. After a restart, $JAVA_HOME returned the right result, but Tomcat doesn't see it. Still the same error. Tomcat is a system service, so it should load at startup, independent of logins.
    – SPRBRN
    Mar 13, 2015 at 17:46
  • @goldilocks I tried to set JAVA_HOME in /etc/environment, but the system still starts with an error that the variable is not set (during startup). Jul 14, 2015 at 20:42

1 Answer 1


Look into /etc/init.d/tomcat7 startup file, you'll see it requires a default-java link against your JDK directory.

$ cd /usr/lib/jvm $ sudo ln -s jdk-8-oracle-arm-vfp-hflt default-java

Done - now you can start your tomcat7 instance.

  • I still get the no JDK found - please set JAVA_HOME message, even with the link. I added export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt to .bashrc in /home/pi, /root and in /etc/environment. I get the message on startup as well as when trying to start Tomcat using sudo service tomcat7 start. Jul 14, 2015 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.