I'm trying to upgrade my servers to Java8 from Java7 so that they will run my webapps under Java8. On one of my machines I'm getting the following error and I'm not sure what is still referring to java-7

$ sudo service tomcat7 start
 * Starting Tomcat servlet engine tomcat7
start-stop-daemon: unable to stat /usr/lib/jvm/java-7-oracle/bin/java (No such file or directory)

This server is Ubuntu 14.10 (Utopic). I have uninstalled all java-7 and java-6 packages. I now have the following java packages installed:

  • openjdk-8-jdk
  • openjdk-8-jre
  • openjdk-8-source
  • oracle-java8-installer

I have a /usr/share/tomcat7/bin/setenv.sh file with the line:

JAVA_HOME=`readlink -f  /usr/bin/javac | sed 's|/bin/javac||g'`

The java alternatives seems to point to the right thing:

$ update-alternatives --display java
java - manual mode
  link currently points to /usr/lib/jvm/java-8-oracle/jre/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1069
  slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-8-oracle/jre/bin/java - priority 1080
  slave java.1.gz: /usr/lib/jvm/java-8-oracle/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-8-oracle/jre/bin/java'.

Java 8 works correctly:

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

I can't figure out why something is still looking for java-7. The following grep reveals no clues:

$ sudo grep -r java-7 /etc/tomcat7 /etc/init.d/tomcat7 /var/lib/tomcat7/ /usr/share/tomcat7

What is causing tomcat7 to look for java-7 still?

1 Answer 1


The reference was in /etc/default/tomcat7:


I updated that to java-8 and everything starts just fine. Here is my entire script for doing the upgrade:


set -e

sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update

sudo apt-get --force-yes -y install \
    openjdk-8-jdk \
    openjdk-8-jre \
    openjdk-8-source \

sudo apt-get --force-yes -y remove \
    openjdk-6-jdk \
    openjdk-6-jre \
    openjdk-6-jre-headless \
    openjdk-6-source \
    openjdk-7-jdk \
    openjdk-7-jre \
    openjdk-7-jre-headless \
    openjdk-7-source \
    oracle-java6-installer \

echo "Setting java provider to java-8-oracle"
sudo update-java-alternatives --set java-8-oracle || true
currentjava=`update-alternatives --display java | grep 'points to'`
if [ "$currentjava" == "${currentjava/java-8-oracle/}" ]
    echo "Java not set properly"
    exit 1

sudo sed -i -r "s#^JAVA_HOME=.*#JAVA_HOME=\`readlink -f  /usr/bin/javac | sed 's|/bin/javac||g'\`#" /etc/default/tomcat7

sudo service tomcat7 stop
sleep 4
sudo killall -u tomcat7 || true
sleep 3
sudo service tomcat7 start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .