jva
jva

Reputation: 2805

Is there a way to determine Java version without seeing shell output?

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.

Upvotes: 3

Views: 1385

Answers (5)

Vinay Sajip
Vinay Sajip

Reputation: 99530

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

java -version >out.txt 2>&1

Upvotes: 1

beggs
beggs

Reputation: 4195

System.getProperty("java.version")

Upvotes: 7

skaffman
skaffman

Reputation: 403601

The version message gets printed to STDERR, not STDOUT.

If you're on linux/unix, try

java -version >& version.txt

instead

Upvotes: 7

jtbandes
jtbandes

Reputation: 118781

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

java -version > out.txt 2>&1

Upvotes: 1

Robert Munteanu
Robert Munteanu

Reputation: 68328

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)

Upvotes: 1

Related Questions