44

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.

Eliran Malka
  • 15,821
  • 6
  • 77
  • 100
Carcophan
  • 1,508
  • 2
  • 18
  • 38
  • try to define `_JAVA_OPTIONS="-Djava.io.tmpdir=$HOME/tmp"` as an environment variable. [Source](http://www.coderanch.com/t/428867/Linux-UNIX/Picked-up-JAVA-OPTIONS) – Eliran Malka Jul 27 '12 at 08:27
  • 1
    This still shows the "Picked up" message, for example: `JAVA_OPTIONS="-Djava.io.tmpdir=$HOME/tmp" java` gives me `Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/home/foouser/tmp` – Carcophan Jul 27 '12 at 09:15
  • 7
    I [re-asked and answered](http://superuser.com/q/585695/67265) the question on superuser, I hope it’s useful. – flying sheep Apr 21 '13 at 13:49
  • Don't put passwords here. Rather use this for general options and passwords should be passed as parameters to scripts. – Jus12 Sep 26 '15 at 14:40

2 Answers2

34

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.
eloibm
  • 899
  • 2
  • 11
  • 27
jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • 3
    syntax for suppressing the options output: http://superuser.com/questions/585695/suppressing-the-picked-up-java-options-message – michael May 06 '15 at 09:26
  • 1
    https://bugs.openjdk.java.net/browse/JDK-8039152 won't fix – Vadzim Nov 21 '16 at 15:52
13

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"'
spelufo
  • 634
  • 3
  • 19
David Martin
  • 179
  • 1
  • 3
  • 1
    Actually it doesn't answer the question. =) – Jan. Dec 13 '12 at 15:17
  • 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. – Carcophan Dec 13 '12 at 17:35
  • @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. – David Martin Dec 14 '12 at 15:59
  • 2
    'unset _JAVA_OPTIONS' was all I'm looking for .. – 7kemZmani Apr 23 '17 at 05:36