I have a jar named helloDemo
. I have double clicked on the jar file to run, assume it is running now. Now in another program I want to get all the jar file names and print them which are currently running or active in my system (windows7). Is there any way to do it ? I have goggled for it but no luck. Can anybody please help me on this ?
Asked
Active
Viewed 1,567 times
0

NiziL
- 5,068
- 23
- 33

Sumon Bappi
- 1,937
- 8
- 38
- 82
-
What operating system are you using? In what application did you double-click the jar files? – valir May 02 '15 at 10:05
-
windows 7, just on distributed jar – Sumon Bappi May 02 '15 at 10:12
-
Well, you should see the corresponding java.exe process in the task manager, AFAICT. However, if you need to get the list in some programe, then you should enumerate these processes and system scripting facilities are quite limited under Windows. – valir May 02 '15 at 10:15
-
can you give some code example please – Sumon Bappi May 02 '15 at 10:25
-
Well, I dont have Window 7, sorry. – valir May 02 '15 at 10:28
-
doesn't matter, thanks anyway – Sumon Bappi May 02 '15 at 10:28
2 Answers
1
You can list all Java processes on the local machine or a remote machine with using Java Virtual Machine Process Status Tool - jps
:
jps [options] [hostid]
options
- list of optionshostid
- host identifier of the remote machine.
For more information:
0
I assume you have successfully created a runnable jar, and not a simple archive, (if you're not sure about that, this question might be helpful: How to make an executable jar file) and HelloDemo.java
looks like the further code (or something more elaborate) to ensure it will run a long time.
public class HelloDemo {
public static void main(String[] args){
while(true);
}
}
Ok, this one runs a very long time ;P
So, you're able to launch a bunch of java process, and now want to list them. Well, stackoverflow is all you need:
- How to get a list of current open windows process with java
- List of Java processes which is a linux-specific answer
- Aleksey Bybov's answer about
jps