How to set Process Name for my own application

后端 未结 2 1070
陌清茗
陌清茗 2021-01-06 07:21

I have created a simple java 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 Na

相关标签:
2条回答
  • 2021-01-06 07:36

    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

    0 讨论(0)
  • 2021-01-06 07:47

    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

    0 讨论(0)
提交回复
热议问题