How can I set the process name for a Java-program? [duplicate]

Solution 1:

I don't know if this is possible, but you could use a command line tool that comes with the JDK called 'jps'. It's like *nix ps, but just Java programs instead. jps -v shows all the arguments you have passed to java.

Also, I have seen people attach a "process name" to their java processes by adding an unused -Dmyprocessname to the args.

Solution 2:

as @omerkudat said:

jps -v

prints out all java processes {processID, params list} If the params list is not enough to recognize the applications you need, try adding some dummy params when running them:

java -Dname=myApp -cp  myApp.jar some.client.main.MainFrame

This will print like:

7780 MainFrame -Dname=myApp

and you can use the process ID to kill / monitor it.