How can I give my Java application a unique process name?

后端 未结 6 1020
灰色年华
灰色年华 2020-12-01 12:25

I\'ve noticed that when I start Netbeans it shows up in the task manager as netbeans.exe as all my own Java applications show up as java.exe or

相关标签:
6条回答
  • 2020-12-01 13:08

    IMO the best option is to choose one of the many open source launchers. They all provide a nicer deployment container than java.exe and a batch file.

    I've compiled a list of them after a brief search on google (in no particular order and may not be exhaustive):

    • NSIS
    • Janel (dead link)
    • JSmooth
    • Launch4J
    • WinRun4J

    (full disclosure: i work on winrun4j)

    0 讨论(0)
  • 2020-12-01 13:11

    The process name is the name of the JVM. So if you rename the jvm you have an other process name. There are some tools which can do that for you. For example Launch4J

    0 讨论(0)
  • 2020-12-01 13:13

    There are mainly 2 approaches: one is as already described: using tools like Launch4j, WinRun4J to create native Windows launchers.

    Another approach that seems better is to use Apache Procrun to wrap the java application as a Windows service. During the install service process, we can give the process an meaningful name such as OurApp.exe.

    All we need do is rename prunsrv.exe to OurApp.exe and replace every occurrence of prunsrv.exe in our install|start|stop|uninstall service scripts to MyApp.exe.

    See more from Using Apache Procrun to Rename Process Name of a Java Program in Windows

    0 讨论(0)
  • 2020-12-01 13:15

    Just answered this a second ago here: Get JVM to grow memory demand as needed up to size of VM limit?

    It's actually a lot easier than folks are saying (but you do have to have a c/c++ compiler handy).

    0 讨论(0)
  • 2020-12-01 13:19

    Not easily. The easiest way (but not nice!) would be to simply copy the java.exe (only 68k on my system, so perhaps practical!)

    If you're worried about identifying which java process is which (e.g. is one consuming memory/CPU etc.), use the standard tool jps to identify the Java processes

    0 讨论(0)
  • 2020-12-01 13:20

    Netbeans and Eclipse both ship with an .exe file that in turns launches a JVM. The exe itaself probably does nothing after launching the VM. You see the NetBeans javaw.exe in the Task Manager also, I suspect.

    So you'll need to write a native exe (using some windows tool) that does a similar thing.

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