Is there a way to determine the version of Java without looking at shell output?

I have the following problem.

I am executing an OS command line from an Oracle database that is executing an external jar file with some parameters. I can not see the shell output, but I can connect with another user to the same server via ssh / ftp and read the files. There are several versions of Java on this server, and I would like to see which Oracle uses. Is it possible?

And before you start - no,

java -version > out.txt

does not work. It prints the console version of Java and creates an empty file.

+3
source share
5 answers

The version message is printed in STDERR, not in STDOUT.

If you are using linux / unix try

java -version >& version.txt

instead

+7
source
System.getProperty("java.version")
+7
robert@rm:~> java -version >  out.txt 2>&1 
robert@rm:~> cat out.txt 
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
+1

It is strange, it prints the version for stderr. If the console is * nix, do the following:

java -version > out.txt 2>&1
+1
source

I assume the Unix / Linux server, if so, try:

java -version> out.txt 2> & 1

+1
source

Source: https://habr.com/ru/post/1712753/


All Articles