I'd like to know how it is started. What is the command to start this java process ? What I mean is I have one running java process, and I'd like to know the command to start it, such as what is the main class and what is the arguments, etc.
Any tool for that ? Thanks

- 25,496
- 45
- 109
- 159
-
How about `java className`, where `className` is the name of the Java class containing an executable `main()` method? – Tim Biegeleisen Sep 08 '15 at 03:35
-
I think he wants to know what arguments... etc were used when starting the java process by reading the values from the process itself (i'm sure the JVM stores them somewhere). – Serdalis Sep 08 '15 at 03:36
-
What I mean is I have one running java process, and I'd like to the command to start it, such as what is the main class and what is the arguments, etc. – zjffdu Sep 08 '15 at 03:36
-
I think you may want to look at [this question about reading JVM arguments](http://stackoverflow.com/questions/1518213/read-java-jvm-startup-parameters-eg-xmx) – Serdalis Sep 08 '15 at 03:38
-
6If you are on linux, try in the terminal `ps -ef | grep java` and search in the list the process you want, the last "column" of the list is the command line used to start the process – morgano Sep 08 '15 at 03:41
3 Answers
There is a command line tool that comes with the JDK: jps, that will give you the list of java processes being run at the moment you execute the command, the arguments given to the method main and the parameters used for the JVM. Try this:
path\to\jdk\bin\jps -m -l -v
It won't give you the exact command used to start the process, but it will give you a hint of how to "rebuild" that command.
For more info, if you are on a decent distro of linux, try man jps
or if you are on Windows, see the Oracle documentation about jps.

- 17,210
- 10
- 45
- 56
Your question wasn't clear. If you are looking to find the command that launched this process than you can look at the property sun.java.command
. This will give you the main class name and arguments passed to it. java.class.path
property gives you the class path. You can get the arguments passed to the java command itself by using ManagementFactory.getRuntimeMXBean().getInputArguments()
method. Using all these you should be able to reconstruct the java command.

- 5,353
- 1
- 17
- 28
If you use Windows, you can use the Taskmanager, go to the Process/Details Tab, where you can see the PID for each Process. There you can add a column for the command line (e.g. in German its "Befehlszeile", i'm not sure how that column is labeled in English). Then just look at the java.exe/javaw.exe Processes.
You could also use the alternative Taskmanager from Microsoft, Process Explorer, afaik there you can just click right on a process and select details.

- 3,673
- 26
- 40