34

When should each of these environment variables be used?

1

2 Answers 2

22

JAVA_TOOL_OPTIONS is read by some JDK tools, but has limited applicability.

JAVA_OPTS is a convention used by Apache Tomcat and some other apps, but is not read directly by any JDK tools published by Sun/Oracle, AFAIK.

From: https://forums.oracle.com/forums/thread.jspa?messageID=6438415

JAVA_OPTS is not an environment variable that the java executable will recognize on it's own. Instead, various scripts which wrap the start up of java will often use an environment variable named JAVA_OPTS to configure the java executable (for example, the tomcat startup script does this).

Sign up to request clarification or add additional context in comments.

Comments

19

see "what is" doc and "tool options" doc

Basically, the JAVA_TOOL_OPTIONS is intended for use by development tools, monitoring tools and the like whereas JAVA_OPTS is used for running 'general' Java programs, I think people tend to mix and match somewhat (from what Google has shown me example wise).

3 Comments

One real-world example: JAVA_TOOL_OPTIONS is used by TeamCity CI to pass settings to step runners such as "Simple Build Tool" (Scala SBT), and users need use JAVA_OPTS in order to not clobber the implicit system parameters passed on by the TeamCity server such as - http_proxy could be one of these.
Another difference is that when JAVA_TOOL_OPTIONS is defined, a message is always echoed to stdout, like Picked up JAVA_TOOL_OPTIONS: -XX:+UseG1GC -Xmx4G.
If it's of value for readers using later JVMs, those links above can be found also for java 17 or java 11.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.