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?
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 addedexport 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 usingsudo service tomcat7 start
.Marcel Korpel– Marcel Korpel2015年07月14日 21:02:31 +00:00Commented Jul 14, 2015 at 21:02
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).JAVA_HOME
in/etc/environment
, but the system still starts with an error that the variable is not set (during startup).