This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hello, Suppose we are running two java (say swing appln) applications on a windows machine. In that case we can see two java processes running in windows task manager. Can we identify which java process is running for which application? Thanks in advance.
There is no easy way to do this. If you want to know if one particular Java application is running you could use a marker when it starts up: possibly have it create a lock file or open a connection to a port.
Depending on the version of Windows you are using you might be able to use Windows Scripting Host's Shell object to start your Java app. from a WSF and get the PID. I've never tried it, but it theoretically should be possible. Of course it will mean you need to write two programs rather than one...
I am not sure why you want to do this but you can take the help of a profiler if your need is to increase the performance of a program by checking the consumption of system resources. Profiler is a computer program that can track the performance of another program by checking information�s collected while the code is executed. A profiler can identify the time used by or frequency of use of various portions of the second program. Typically this information is used to identify those portions of the second program that consume the most time. These time consuming parts are then targeted for optimisation. Also a profiler can be useful for debugging.
-------------- Naveen Vooka www.devsquare.com DevSquare - Online Application Development
If the processes have different command lines, then it is possible. Task Manager can't display full command line, but Sysinternals Process Explorer (enhanced task manager) or other similar program can. [ September 27, 2005: Message edited by: Vlado Zajac ]