title: Ubuntu 16.04: Tomcat 8 won't start with setenv.sh
body: <p>I have created a <code>setenv.sh</code> file in my <code>tomcat8/bin</code> directory with the following content:</p>
  
  <pre><code>#!/bin/sh
  #
  # ENVARS for Tomcat
  #
  export CATALINA_HOME="/usr/share/tomcat8"
  
  export CATALINA_BASE="/usr/share/tomcat8"
  
  export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"
  
  # TDS specific ENVARS
  #
  # Define where the TDS content directory will live
  #   THIS IS CRITICAL and there is NO DEFAULT - the
  #   TDS will not start without this.
  #
  CONTENT_ROOT=-Dtds.content.root.path=/var/lib/tomcat8/content
  
  # set java prefs related variables (used by the wms service, for example)
  JAVA_PREFS_ROOTS="-Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs \
                    -Djava.util.prefs.userRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs"
  
  #
  # Some commonly used JAVA_OPTS settings:
  #
  NORMAL="-d64 -Xmx4096m -Xms512m -server -ea"
  HEAP_DUMP="-XX:+HeapDumpOnOutOfMemoryError"
  HEADLESS="-Djava.awt.headless=true"
  
  #
  # Standard setup.
  #
  JAVA_OPTS="$CONTENT_ROOT $NORMAL $MAX_PERM_GEN $HEAP_DUMP $HEADLESS $JAVA_PREFS_ROOTS"
  
  export JAVA_OPTS
  </code></pre>
  
  <p>Unfortunately tomcat won't start after saving this file:</p>
  
  <pre><code>tomcat8.service - LSB: Start Tomcat.
     Loaded: loaded (/etc/init.d/tomcat8; bad; vendor preset: enabled)
     Active: failed (Result: exit-code) since Do 2016-05-26 16:45:51 CEST; 6min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 5903 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=1/FAILURE)
  
  Mai 26 16:45:46 student systemd[1]: Starting LSB: Start Tomcat....
  Mai 26 16:45:46 student tomcat8[5903]:  * Starting Tomcat servlet engine tomcat8
  Mai 26 16:45:51 student tomcat8[5903]:    ...fail!
  Mai 26 16:45:51 student systemd[1]: tomcat8.service: Control process exited, code=exited status=1
  Mai 26 16:45:51 student systemd[1]: Failed to start LSB: Start Tomcat..
  Mai 26 16:45:51 student systemd[1]: tomcat8.service: Unit entered failed state.
  Mai 26 16:45:51 student systemd[1]: tomcat8.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>I need this configuration for an external server application (thredds data server). I suppose it could be something wrong about the JAVA_HOME variable. I copied the path which i found out with <code>sudo update-alternatives --config java</code> (see <a href="https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04" rel="nofollow">this tutorial</a>). </p>
  
  <p>Can someone tell me whats going wrong?</p>