Re: javaSysMon

268 views
Skip to first unread message

Jez Humble

unread,
Mar 10, 2010, 12:30:24 AM3/10/10
to Ivan Stefko, javas...@googlegroups.com
Hey Ivan

I've copied in the Google group - hope that's OK.

It turns out that to get the command line arguments in Windows you need to read the virtual memory address space of the process as described here: http://forum.sysinternals.com/forum_posts.asp?TID=6510 - you need to do the same kind of thing to get environment variables I believe.

To simplify somewhat, Linux treats the entire command line as a string, whereas Windows parses it.

At the moment, JavaSysMon is (intentionally) stupid when it comes to this kind of information. I think the right way to do it is to present separate methods to get command line arguments (and environment vars, when we come to do that) - which means adding a method such as public String[] getArguments()to the com.jezhumble.javasysmon.ProcessInfo class. That will in turn require updating the native code for each of the supported OSes.

Unfortunately I don't have the time to work on this right now. If you want to fork the project on GitHub and have a go yourself, I'll be happy to provide feedback and answer questions.

Thanks,

Jez.

On 9 March 2010 18:19, Ivan Stefko <ivan....@seznam.cz> wrote:
Hi Jez, 
    thanks for your reply. I have another question. 
I’m using this code:

 

running processes:

-          java –jar myApp.jar myArg1 myArg2

-          ....

 Java code:

ProcessInfo[] processInfo = monitor.processTable();

String myCommand = processInfo.getCommand

 

Result/Linux :

=> myApp.jar myArg1 myArg2 ...

 

Result/windows is without parameter :

=> myApp.jar

 

 So I’m looking for some solution for it – how can I display also parameters/argumets on Windows platform?

 

thanks for advice. 


ivan


On 2 March 2010 10:45, Jez Humble <j...@india.com> wrote:
Hey Ivan

JavaSysMon tells you information about the operating system's processes. It has no special information about the JVM, or about threads inside a Java process. If you're running several Java processes, you can see these within JavaSysMon. To get process info, do something like this:


JavaSysMon monitor = new JavaSysMon();

ProcessInfo[] processInfo = monitor.processTable();

Thanks,

Jez.

On 2 March 2010 08:17, Ivan Stefko <ivan....@seznam.cz> wrote:
Hi, 
    i found your project and i have interest of it. i need to list all jvms processes in java and i'm looking for some solution for it. of course - i can can use jps from java_home or tool.jar from java_home .. but tool.jar has 12MB .. so is not good idea because of listing processes. 
    I have problem with javaSysMon library because I can't find some example for use. Could you help me with it?

I need: list all running JVM processes from java. 

thx, 

ivan



Reply all
Reply to author
Forward
0 new messages