How can I find the exact version of a different Java process (onWindows)

D

dw

I have a Java 5 process running on the same Windows machine. I need to
be able to find out what exact version of java this process is
running.

I have found a tool called JPS (http://java.sun.com/j2se/1.5.0/docs/
tooldocs/share/jps.html) that can find out command-line arguments of a
process. Does anyone know how JPS works? Presumably whatever method
JPS uses to get the command line args could also be used to get the
java version.

On UNIX I can just use ps to get the complete path to the command
line, so I have no need of a special tool.

Thanks,

D
 
J

Joshua Cranmer

dw said:
I have a Java 5 process running on the same Windows machine. I need to
be able to find out what exact version of java this process is
running.

Did you try System.getProperty("java.version")?
 
M

Mike Schilling

dw said:
I have a Java 5 process running on the same Windows machine. I need to
be able to find out what exact version of java this process is
running.

I have found a tool called JPS (http://java.sun.com/j2se/1.5.0/docs/
tooldocs/share/jps.html) that can find out command-line arguments of a
process. Does anyone know how JPS works? Presumably whatever method
JPS uses to get the command line args could also be used to get the
java version.

On UNIX I can just use ps to get the complete path to the command
line, so I have no need of a special tool.

The Windows Process Explorer will tell you lots of neat stuff about the
current processes, including the exact path of the executable. That usually
makes the version obvious, or if not you can run that executable with
the -version flag. If you google for "Windows Process Explorer ", you'll
find places to download it.
 
A

Arne Vajhøj

dw said:
I have a Java 5 process running on the same Windows machine. I need to
be able to find out what exact version of java this process is
running.

I have found a tool called JPS (http://java.sun.com/j2se/1.5.0/docs/
tooldocs/share/jps.html) that can find out command-line arguments of a
process. Does anyone know how JPS works? Presumably whatever method
JPS uses to get the command line args could also be used to get the
java version.

On UNIX I can just use ps to get the complete path to the command
line, so I have no need of a special tool.

Most likely making some OS specific call in C to get the info.

But check the source code for OpenJDK and see if jps is there.

Arne
 
P

Philipp

I have a Java 5 process running on the same Windows machine. I need to
be able to find out what exact version of java this process is
running.

If you have control over both code sources, you can add an RMI server
(http://java.sun.com/docs/books/tutorial/rmi/index.html) to the code
for which you want to get the Java version. It would contain a class
which returns System.getProperty("java.version").

This is also cross platform

HTH Phil
 
D

dw

If you have control over both code sources, you can add an RMI server
(http://java.sun.com/docs/books/tutorial/rmi/index.html) to the code
for which you want to get the Java version. It would contain a class
which returns System.getProperty("java.version").

This is also cross platform

HTH Phil

Thanks for all the responses. In the end I used a VB Script:

'
' Invoke from DOS with cscript PS.vbs
' Lists the PID and full command line for each process.
'
Set Processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\
\.\root\cimv2").ExecQuery("select * from Win32_Process")
For each Process in Processes
PList = PList & Process.ProcessId & " " & Process.CommandLine &
vbLf
Next
WScript.Echo PList
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top