tags:

views:

242

answers:

5

I have a following problem.

I am executing an OS command line from within Oracle database that executes an external jar file with some parameters. I can't see shell output but I can connect with a different user to that same server through ssh/ftp and read files. There are multiple versions of Java on that server and I would like to see which one Oracle is using. Is it possible?

And before you start - no,

java -version > out.txt

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

+1  A: 
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)
Robert Munteanu
+1  A: 

That's odd, it prints the version to stderr. If the console is *nix, do this:

java -version > out.txt 2>&1
jtbandes
+4  A: 

The version message gets printed to STDERR, not STDOUT.

If you're on linux/unix, try

java -version >& version.txt

instead

skaffman
Thant's a neat trick. Does it just redirect stderr or stdout as well?
Robert Munteanu
Just stderr, I think.
skaffman
Thanks a lot. :)
jva
+6  A: 
System.getProperty("java.version")
beggs
I think this is what the OP actually wanted :)
skaffman
OK, apparently not...
skaffman
haha.. C'est la vie...
beggs
+1  A: 

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

java -version >out.txt 2>&1

Vinay Sajip