Suppressing the "Picked up _JAVA_OPTIONS" message

55,910

Solution 1

From looking at the relevant source code (arguments.cpp in openjdk, line 2492), there is no way to control the output of this message.

The only thing I could say is that it is printed to stderr. So you could wrap your commands to redirect stderr to /dev/null (if there wasn't anything else you cared about on stderr).

  • Or write a java wrapper script which filtered out this message.
  • Or submit a feature request to the openjdk project, although this won't solve your immediate problem.

Solution 2

Where is _JAVA_OPTIONS being set? In your .bashrc?

Use an alias instead, e.g.

alias java="`which java` -Dwhatever"

Actually, it is not necessary to know where it is being set to make this work:

_SILENT_JAVA_OPTIONS="$_JAVA_OPTIONS"
unset _JAVA_OPTIONS
alias java='java "$_SILENT_JAVA_OPTIONS"'
Share:
55,910
Carcophan
Author by

Carcophan

Tools engineer in Cambridge UK

Updated on April 27, 2020

Comments

  • Carcophan
    Carcophan about 4 years

    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.

  • Jan.
    Jan. over 11 years
    Actually it doesn't answer the question. =)
  • Carcophan
    Carcophan over 11 years
    It is being set as part of a wrapper script which runs java with a sensible minimum amount of memory if the options isn't already set. Therefore I don't think I can use this solution.
  • Admin
    Admin over 11 years
    @Jan yes it does, as the question was asked. I didn't know the deeper context. And it works for me as I had the same problem and resolved it (seeing this unwanted message when running java programs in bash), so I thought I'd pass it on. Maybe useful to someone with my particular circumstances going by the same question.
  • michael
    michael about 9 years
    syntax for suppressing the options output: superuser.com/questions/585695/…
  • Vadzim
    Vadzim over 7 years
  • 7kemZmani
    7kemZmani about 7 years
    'unset _JAVA_OPTIONS' was all I'm looking for ..