Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prevent running the same application twice

801416Aug 21 2007 — edited Aug 25 2007
Hi all,
I want to prevent running my application(from JAR file) for the 2nd time when it is still open. Is there any way to get the process ID for this specific application, so that I can check it every time before it tries to run.
If any JAR file runs, in Windows Task Manager it shows just "javaw.exe". I couldn't find any way to figure out which one is the specific JAR that I'm looking for.
If I read from tasklist and extract only "javaw.exe"as follows:
Runtime.getRuntime().exec("tasklist").getInputStream();
I get the something like this:
. tasklist <<<<<<<<<<<<<<<<<<<<<<,
javaw.exe 2492 Console 0 23,120 K
javaw.exe 2944 Console 0 22,824 K
javaw.exe 2212 Console 0 12,580 K

So, I wouldn't be able to know which one is the ONE I'm looking for.

Can you guys give me any suggesstion?
Please help me.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2007
Added on Aug 21 2007
12 comments
1,156 views