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?
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.