如何为Java应用程序提供唯一的进程名称?

时间:2021-08-03 15:50:33

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 javaw.exe.

我注意到,当我启动Netbeans时,它会在任务管理器中显示为netbeans.exe,因为我自己的所有Java应用程序都显示为java.exe或javaw.exe。

How can I change that so my process names shows up as myapp.exe?

如何更改,以便我的进程名称显示为myapp.exe?

6 个解决方案

#1


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

进程名称是JVM的名称。因此,如果重命名jvm,则还有其他进程名称。有一些工具可以帮到你。例如Launch4J

#2


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.

IMO最好的选择是选择众多开源发射器中的一个。它们都提供了比java.exe和批处理文件更好的部署容器。

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

我在google上进行了简短的搜索后编制了一个列表(没有特别的顺序,也可能不详尽):

(full disclosure: i work on winrun4j)

(完全披露:我在winrun4j上工作)

#3


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

不容易。最简单的方法(但不是很好!)就是简单地复制java.exe(我的系统只有68k,所以也许实用!)

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

如果您担心识别哪个java进程(例如消耗内存/ CPU等),请使用标准工具jps来识别Java进程

#4


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.

Netbeans和Eclipse都附带一个.exe文件,该文件依次启动JVM。 exe itaself在启动VM后可能什么都不做。我怀疑,您还可以在任务管理器中看到NetBeans javaw.exe。

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

因此,您需要编写一个执行类似操作的本机exe(使用一些Windows工具)。

#5


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

刚刚在这里回答了这个问题:获取JVM以根据需要增加内存需求以达到VM限制的大小?

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

它实际上比人们说的容易得多(但你必须有一个方便的c / c ++编译器)。

#6


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

主要有两种方法:一种是已经描述的:使用Launch4j,WinRun4J等工具创建本机Windows启动器。

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.

另一种似乎更好的方法是使用Apache Procrun将Java应用程序包装为Windows服务。在安装服务过程中,我们可以为进程提供一个有意义的名称,例如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.

我们所需要做的就是将prunsrv.exe重命名为OurApp.exe,并将我们的安装|启动|停止|卸载服务脚本中每次出现的prunsrv.exe替换为MyApp.exe。

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

有关详细信息,请参阅使用Apache Procrun重命名Windows中Java程序的进程名称

#1


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

进程名称是JVM的名称。因此,如果重命名jvm,则还有其他进程名称。有一些工具可以帮到你。例如Launch4J

#2


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.

IMO最好的选择是选择众多开源发射器中的一个。它们都提供了比java.exe和批处理文件更好的部署容器。

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

我在google上进行了简短的搜索后编制了一个列表(没有特别的顺序,也可能不详尽):

(full disclosure: i work on winrun4j)

(完全披露:我在winrun4j上工作)

#3


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

不容易。最简单的方法(但不是很好!)就是简单地复制java.exe(我的系统只有68k,所以也许实用!)

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

如果您担心识别哪个java进程(例如消耗内存/ CPU等),请使用标准工具jps来识别Java进程

#4


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.

Netbeans和Eclipse都附带一个.exe文件,该文件依次启动JVM。 exe itaself在启动VM后可能什么都不做。我怀疑,您还可以在任务管理器中看到NetBeans javaw.exe。

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

因此,您需要编写一个执行类似操作的本机exe(使用一些Windows工具)。

#5


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

刚刚在这里回答了这个问题:获取JVM以根据需要增加内存需求以达到VM限制的大小?

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

它实际上比人们说的容易得多(但你必须有一个方便的c / c ++编译器)。

#6


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

主要有两种方法:一种是已经描述的:使用Launch4j,WinRun4J等工具创建本机Windows启动器。

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.

另一种似乎更好的方法是使用Apache Procrun将Java应用程序包装为Windows服务。在安装服务过程中,我们可以为进程提供一个有意义的名称,例如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.

我们所需要做的就是将prunsrv.exe重命名为OurApp.exe,并将我们的安装|启动|停止|卸载服务脚本中每次出现的prunsrv.exe替换为MyApp.exe。

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

有关详细信息,请参阅使用Apache Procrun重命名Windows中Java程序的进程名称