I'm trying to configure tomcat8 on Red Hat Enterprise Linux 7. I get the configuration file from a Debian version (that I have set up), which is:


JAVA_OPTS='${JAVA_OPTS} -Dfile.encoding=UTF-8'
JAVA_OPTS='${JAVA_OPTS} -XX:+UseConcMarkSweepGC'

# memory
JAVA_OPTS='${JAVA_OPTS} -Xmx1024m -Xm1024m'

# logging
JAVA_OPTS='${JAVA_OPTS} -Dlogback.configurationFile=$CATALINA_BASE/conf/logback.xml'


With Red Hat this configuration doesn't work; I get this error:

Error: Could not find or load main class ${JAVA_OPTS}
Caused by: java.lang.ClassNotFoundException: ${JAVA_OPTS}

But when I erase the ${JAVA_OPTS} and concatenates the JAVA_OPTS on a single line:

JAVA_OPTS='-Djava.awt.headless=true -Dfile.encoding=UTF-8 -XX:+UseConcMarkSweepGC -Xmx1024m -Xm1024m' -Dlogback.configurationFile=$CATALINA_BASE/conf/logback.xml'

It works.

I've also tried to replace ${JAVA_OPTS} with $JAVA_OPTS, %JAVA_OPTS%. Do you have any idea why tomcat8 is not recognizing the ${JAVA_OPTS}?


  • Is this configuration file supposed to be a shell script? – muru Jun 6 '19 at 6:25
  • Mmmh... good question. Maybe that the thing; in Debian it can be written as a shell script while in rhel not. Could it be possible? – Bastian Nanchen Jun 6 '19 at 6:41
  • 1
    If it is, try using double quotes instead of single quotes. – muru Jun 6 '19 at 6:55

Single quotes tell shell not to interpret the commands/variables inside. So you have no expand/interpret ${JAVA_OPTS} construction. Try to make it on this way (with double quotes):


JAVA_OPTS="${JAVA_OPTS} -Dfile.encoding=UTF-8"
JAVA_OPTS="${JAVA_OPTS} -XX:+UseConcMarkSweepGC"

# memory
JAVA_OPTS="${JAVA_OPTS} -Xmx1024m -Xm1024m"

# logging
JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=$CATALINA_BASE/conf/logback.xml"


Also AFAIK on contemporary versions of java you should use -Xms instead of -Xm

  • I've tested with double quotes but I get the same error as before. – Bastian Nanchen Jun 6 '19 at 8:13
  • @BastianNanchen, so you have is somewhere else with single quotes, check it – Romeo Ninov Jun 6 '19 at 8:25
  • I'm not sure to understand your phrase; are you insinuating that there is an existing JAVA_OPTS statement with single-quote? – Bastian Nanchen Jun 6 '19 at 8:57
  • @BastianNanchen, correct. – Romeo Ninov Jun 6 '19 at 8:59
  • I'm pretty sure that I've replaced all the single-quotes with double ones. – Bastian Nanchen Jun 6 '19 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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