This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java Detect another Program run? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Detect another Program run?" Watch "Java Detect another Program run?" New topic
Author

Java Detect another Program run?

J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90

Greetings everyone!

I never experienced as .net developers
neither also as c++ or C# thus I hack a lack knowledge of this topic.

But i'm still curious mode right now, and I'm still looking around.

How could java detect another program is currently running?
Let's assume this windows environment instead of linux.

My question asking it is that because,
I dunno how to differenciate between one and another frame (running program)
that currently run.

Someone say, ID? I really dunno, what's that. ID of each frame?
is that really exist instead of the memory address of each program?
But memory address is too general and hard to detect,
which in turns different pc has different memory address pointing to that program which is
currently running.


~ Hope there's a guidance.

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1449
    
    6

By another program what exactly do you mean? Instance of the same application or some other application?


Swastik
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3023
    
  35

"jaya inside", please check your private messages regarding an important administrative matter


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Suhrid Karthik
Ranch Hand

Joined: Aug 31, 2008
Posts: 58

You could run an external program from your Java code that can do the checking for you.
For e.g. your Java code can call the "ps" command on Unix or "tasklist" on Windows to check if an external program/process is running.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

But you can't use that with Java programs since all JVM processes are called "java.exe".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Suhrid Karthik
Ranch Hand

Joined: Aug 31, 2008
Posts: 58

Match against the full command line arguments to "java" to resolve ambiguities.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

I'm not sure if that's possible in Windows. I've done a bit of process programming in Windows itself, using PROCESSENTRY32, and the parameters are not part of that structure.
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
Suhrid Karthik wrote:You could run an external program from your Java code that can do the checking for you.
For e.g. your Java code can call the "ps" command on Unix or "tasklist" on Windows to check if an external program/process is running.

well sure, it's the alternative way out perhaps. I'm also thinking that way now...
But, it would be caught upon the UAC User Account Cridential... such as pop up asking permission under
latest windows... omg.

but anyway, Robprime gave us something else
I'm not sure if that's possible in Windows. I've done a bit of process programming in Windows itself, using PROCESSENTRY32, and the parameters are not part of that structure.


what's that?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

It's a native struct which can be used in JNI.
 
Consider Paul's rocket mass heater.
 
subject: Java Detect another Program run?
 
Similar Threads
new to write code, pls help!
Garbage Collection and Virtual Memory
JFrame.setSize() calls ignored until after JFrame.show()
Exact Difference between c and java
stack(storing of function)