Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How can I find the exact version of a different Java process (onWindows)

Reply
Thread Tools

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

 
 
dw
Guest
Posts: n/a
 
      08-04-2009
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
 
Reply With Quote
 
 
 
 
Joshua Cranmer
Guest
Posts: n/a
 
      08-04-2009
dw wrote:
> 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")?


--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      08-04-2009
dw wrote:
> 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.


 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      08-04-2009
dw wrote:
> 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
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      08-04-2009
Joshua Cranmer wrote:
> dw wrote:
>> 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")?


I think he means from another process.

Arne
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-04-2009
On Mon, 3 Aug 2009 18:25:59 -0700 (PDT), dw <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>I have a Java 5 process running on the same Windows machine.


java -version
will tell you the version number.

Internally, you can look at various system properties.
see http://mindprod.com/jgloss/properties.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Patriotism is fierce as a fever, pitiless as the grave, blind as a stone, and as irrational as a headless hen."
~ Ambrose Bierce (born: 1842-06-24 died: 1914 at age: 71)
 
Reply With Quote
 
Philipp
Guest
Posts: n/a
 
      08-04-2009
On Aug 4, 3:25*am, dw <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
dw
Guest
Posts: n/a
 
      08-05-2009
On Aug 4, 2:06 am, Philipp <(E-Mail Removed)> wrote:
> On Aug 4, 3:25 am, dw <(E-Mail Removed)> wrote:
>
> > 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


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=impersonat e}!\
\.\root\cimv2").ExecQuery("select * from Win32_Process")
For each Process in Processes
PList = PList & Process.ProcessId & " " & Process.CommandLine &
vbLf
Next
WScript.Echo PList
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
how can I find the exact header file including a struct variable? eg. DIR? hankssong C Programming 9 12-03-2006 07:37 AM



Advertisments