1

I am trying to run java -XshowSettings:properties -version. I require the java.vendor and java.version properties. I've been trying to store this information into a file by trying to stream it into the file using >>, however it will not work.

I've tried java -XshowSettings:properties -version >> properties.txt, however trying cat properties.txt yields an empty file. I've tried java -XshowSettings:properties -version | tee properties.txt, which yields the exact same results. Both times, the console is filled with all the information I need.

I want to prevent it from printing to the console, and only to the file. In fact, I'd be fine with a variable too, though I'd prefer a file to keep track off.

Frontear
  • 1,150
  • 12
  • 25
  • 1
    Possible duplicate of [How to redirect both stdout and stderr to a file](https://stackoverflow.com/q/7526971/608639), [Redirect stderr and stdout in Bash](https://stackoverflow.com/q/637827/608639), etc. – jww Jun 04 '19 at 23:36

1 Answers1

1

Redirect all the output to the properties.txt, like this.

$ java -XshowSettings:properties -version  > properties.txt 2>&1
alsotoes
  • 257
  • 2
  • 11
  • Is it possible to give me a link or a small explanation as to how this works? – Frontear Jun 04 '19 at 23:13
  • 1
    sure thing... in linux you have 3 descriptors 0 means stdin or standard input, 1 means stdout or standard output (all the things that you easily can redirect to a file), and 2 means stderr or standard error, in this case that command is using the descriptor 2 to give the output, so the part 2>&1 what is doing is force the redirection of stderr to stdout and stdout is redirected to the file properties.txt... take a look on this url about descriptors and output redirection http://www.learnlinux.org.za/courses/build/shell-scripting/ch01s04.html – alsotoes Jun 04 '19 at 23:18