title: Multiline JAVA_OPTS in setenv.sh
body: <p>I'm trying to setup my <code>setenv.sh</code> on Ubuntu 12/Tomcat 7.
  Tomcat has been installed with apt-get
  I've tried to create a multiline <code>JAVA_OPTS</code> variable but keep running into error messages.</p>
  
  <pre><code>#!/bin/sh
  export JAVA_OPTS="$JAVA_OPTS -server \
  -Xms512m -Xmx512m"
  
  : not foundtomcat7/bin/catalina.sh: 4: /usr/share/tomcat7/bin/setenv.sh: 
  Using CATALINA_BASE:   /usr/share/tomcat7
  Using CATALINA_HOME:   /usr/share/tomcat7
  Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
  Using JRE_HOME:        /usr/lib/jvm/java-7-oracle/
  Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
  Error: Could not find or load main class
  </code></pre>
  
  <hr>
  
  <pre><code>#!/bin/sh
  export JAVA_OPTS="$JAVA_OPTS -server -Xms512m -Xmx512m"
  
  : not foundtomcat7/bin/catalina.sh: 3: /usr/share/tomcat7/bin/setenv.sh: 
  Using CATALINA_BASE:   /usr/share/tomcat7
  Using CATALINA_HOME:   /usr/share/tomcat7
  Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
  Using JRE_HOME:        /usr/lib/jvm/java-7-oracle/
  Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
  Invalid maximum heap size: -Xmx512m
  Error: Could not create the Java Virtual Machine.
  Error: A fatal exception has occurred. Program will exit.
  </code></pre>
  
  <p>I've updated it to this, but at the echo location only the last line is displayed.</p>
  
  <pre><code>#!/bin/sh
  JAVA_OPTS="$JAVA_OPTS -server -Xms704m -Xmx704m"
  JAVA_OPTS="$JAVA_OPTS -XX:OnOutOfMemoryError=/usr/share/scripts/on_server_crash.sh"
  JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/tomcat7"
  JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=128m -XX:MaxNewSize=256m -XX:NewSize=256m"
  echo $JAVA_OPTS
  JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=12 -XX:MaxTenuringThreshold=0"
  JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSPermGenSweepingEnabled -XX:+DisableExplicitGC"
  JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC -XX:+UseTLAB"
  JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
  JAVA_OPTS="$JAVA_OPTS -javaagent:$NR_JAR -Dnewrelic.environment=production"
  echo $JAVA_OPTS
  export JAVA_OPTS
  </code></pre>
  
  <p>When I try "each command on its own line" without the export option, I get "unrecognized option -server</p>
  
  <pre><code>#!/bin/sh
  JAVA_OPTS="$JAVA_OPTS -server"
  JAVA_OPTS="$JAVA_OPTS -Xms704m"
  JAVA_OPTS="$JAVA_OPTS -Xmx704m"
  JAVA_OPTS="$JAVA_OPTS -XX:OnOutOfMemoryError=/usr/share/scripts/on_server_crash.sh"
  JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
  JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=/var/log/tomcat7"
  JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=128m"
  JAVA_OPTS="$JAVA_OPTS -XX:MaxNewSize=256m"
  JAVA_OPTS="$JAVA_OPTS -XX:NewSize=256m"
  JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=12"
  JAVA_OPTS="$JAVA_OPTS -XX:MaxTenuringThreshold=0"
  JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSIncrementalMode"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSIncrementalPacing"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"
  JAVA_OPTS="$JAVA_OPTS -XX:+CMSPermGenSweepingEnabled"
  JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
  JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
  JAVA_OPTS="$JAVA_OPTS -XX:+UseTLAB"
  JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
  JAVA_OPTS="$JAVA_OPTS -javaagent:$NR_JAR"
  JAVA_OPTS="$JAVA_OPTS -Dnewrelic.environment=production"
  echo JAVA_OPTS
  </code></pre>