How to set Process Name for my own application
I have created a simple jav开发者_开发知识库a networking program. I am using Fedora. whenever I want to see what the processes run on my system I found that for my application the process Name is java. I want give process name for my application. How to give process name.
Thanks Sunil Kumar Sahoo
One way to change the process name of an application is to use a native launcher (or to copy the java
/java.exe
executable to another name).
Personally I've had good results with Launch4j
You could pass a java property to the jvm when you start the process then that should show up when running a ps -eaf and you could even do a ps -eaf|grep myprop to see if it's running.
so you start the app like this:
java -cp . com.whatever.MyApp -DMyAmazingProgram=true
then you should see the MyAmazingProgram=true in the ps output.
Another way would be to start your app from a bash script file e.g, startMyAmazingApp.sh then that should show up in the ps output until the process ends.
That script would have to not exit until the java process finished so you'd need to have a script a bit like this (rough guess):
#!/bin/bash
RESULT=`java -cp com.whatever.MyApp`
HTH
精彩评论