This message is output by all standard versions of Java since (I think Java 5). It is certainly present in the source code from Java 6 through Java 15.
It is output by the java
command when it sees that the JAVA_TOOL_OPTIONS
or _JAVA_OPTIONS
environment variable is set and when the user is not privileged. The behavior is hardwired, and the java
command doesn't provide a way to suppress it. (If you want more precise details, look at the arguments.cpp
file.)
People have requested that Oracle add an option to suppress the message:
JDK-8039152 : Need a way to suppress message when picking up JAVA_TOOL_OPTIONS
but this has been closed as WON'T FIX.
First of all, it is important to understand why this message is output. According to bug report's analysis:
"So that leaves adding an option to suppress the message. Yes, we could do this, but is it a good idea? The reason that the message is issued is that the feature being used is dangerous and the VM should warn about it.
I strongly recommend that we don't try to change this behavior.
03-04-2014"
In short, the message is a WARNING that something potentially dangerous may be happening. Something that could cause java
to behave in unexpected (and possibly even insecure) ways.
So what can you do to make the annoying message go away?
The best solution is to not use those variables. Unset them! There are other ways to pass command options to the java
command that are less dangerous. If the annoying output is coming from some application that relies on those variables ... raise a bug report for the application.
There are other possible solutions; e.g. filtering the message out of the error stream, or expanding JAVA_TOOL_OPTIONS
into the java
command line (see other answers).
I recommend that you DO NOT do either of these things. Why? Because by suppressing the message you are disabling an important safety feature in the java
command.
And if you do decide to suppress the message, DO NOT do it by replacing the standard java
command with a shell alias or a wrapper script. That is really asking for trouble.