Search code examples
bashshellvirtual-machinesystemjava-7

reading vm properties from a shell script XshowSettings


I am trying to capture the output of java -XshowSettings | grep file.encoding but it is not working. I am trying to read a property of java -XshowSettings from a Unix shell script. Normally, it is easy to ready a property by using e.g. printenv | grep JAVA_HOME but in case of java -XshowSetting, grep does not work.

So, I want something like this java -XshowSetting | grep file.encoding, but it does not work. Any idea?


Solution

  • This will solve your problem

    java -XshowSettings 2>&1 | grep file.encoding
    

    You need to combine the standard output and standard error to capture the results. Read more here.