Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How do I use the JAVA_OPTS environment variable?

Writer Matthew Harrington

How do I use the JAVA_OPTS variable to configure a web server (a linux server)?

How can I set -Djava.awt.headless=true using JAVA_OPTS?

6 Answers

JAVA_OPTS is the standard environment variable that some servers and other java apps append to the call that executes the java command.

For example in tomcat if you define JAVA_OPTS='-Xmx1024m', the startup script will execute java org.apache.tomcat.Servert -Xmx1024m

If you are running in Linux/OSX, you can set the JAVA_OPTS, right before you call the startup script by doing

JAVA_OPTS='-Djava.awt.headless=true'

This will only last as long as the console is open. To make it more permanent you can add it to your ~/.profile or ~/.bashrc file.

1

Just figured it out in Oracle Java the environmental variable is called: JAVA_TOOL_OPTIONSrather than JAVA_OPTS

JAVA_OPTS is environment variable used by tomcat in its startup/shutdown script to configure params.

You can set it in linux by

export JAVA_OPTS="-Djava.awt.headless=true" 
0

JAVA_OPTS is not restricted to Tomcat’s Java process, but passed to all JVM processes running on the same machine.

Use CATALINA_OPTS if you specifically want to pass JVM arguments to Tomcat's servlet engine.

1

Actually, you can, even though accepted answer saying that you can't.

There is a _JAVA_OPTIONS environment variable, more about it here

As stated in these links below, you can edit JAVA_OPTS for Wildfly/JBoss in bin/standalone.conf

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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