Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using _JAVA_OPTIONS to set some defaults for Java on RHEL. It works fine but now every time I start java I get the following message

 Picked up _JAVA_OPTIONS: -foo -bar -baz

is it possible to keep the options but suppress the display of this message.

share|improve this question

Java is often called with absolute paths like /usr/bin/java, which makes this answer useless in some cases, and requires more to make it work in others.

That solution I found requires writing a wrapper shell script that redirects STDERR through a filter removing the offending line. It has to be placed in the $PATH before the java binary it wraps and be called with plain java, which java or similar (or your tool has to be configured to use it)

It relies on the bash ability to create a subshell with parentheses (command), and redirect java’s STDERR to its STDIN command1 2> >(command2). Finally, the process in the subshell needs to redirect its filtered input to STDOUT again so that java programs can still use STDERR.

/usr/bin/java "$@" 2> >(grep -v "^Picked up _JAVA_OPTIONS:" >&2)
share|improve this answer

Or you can put this in your shell startup / profile files:

alias java='java "$_SILENT_JAVA_OPTIONS"'
share|improve this answer
that only works when directly invoking java ... through the command line. all java invocations through scripts or other parent processes will be unaffected – flying sheep Dec 7 '15 at 8:22
well, you can change /bin/java to be a shell script that does the same thing if you really want to. – spelufo Dec 7 '15 at 9:58
even if you don't it will unset the options, so other commands will be affected too. It will silence them by not passing them any options :). – spelufo Dec 7 '15 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .