如何重命名 java.exe/javaw.exe 进程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/265762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:42:18  来源:igfitidea点击:

How to rename java.exe/javaw.exe process?

java

提问by Fuangwith S.

Always when I run java application it will display in Windows Task Manager is java.exe or javaw.exe. How to rename java.exe or javaw.exe process without wrapper by other programming languages.

总是当我运行 java 应用程序时,它会在 Windows 任务管理器中显示为 java.exe 或 javaw.exe。如何通过其他编程语言在没有包装器的情况下重命名 java.exe 或 javaw.exe 进程。

采纳答案by gimel

If you are confused by looking at process names that are all the same (java.exe), try to use Process Explorerinstead of Task Manager, and display the command linefield. This way, you can see the classor jararguments that differentiate one process from another.

如果您对完全相同的进程名称 ( java.exe)感到困惑,请尝试使用Process Explorer而不是Task Manager,并显示命令行字段。这样,您可以看到区分一个进程与另一个进程的jar参数。

回答by johnstok

You could use jSmooth:

你可以使用jSmooth

JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications.

JSmooth 是一个 Java 可执行文件包装器。它为您的 Java 应用程序创建本机 Windows 启动器(标准 .exe)。

回答by volley

I suspect operating systems are generally not very fond of processes trying to rename their "image". If this was possible it would for instance be very easy for a virus to impersonate a legitimate process.

我怀疑操作系统通常不太喜欢尝试重命名其“图像”的进程。如果这是可能的,例如,病毒将很容易冒充合法进程。

By the way, you can also use "jps.exe" to list all Java processes and their corresponding main class. "jps.exe" is found in the bin directory of your Java installation.

顺便说一句,您还可以使用“jps.exe”列出所有 Java 进程及其对应的主类。“jps.exe”位于 Java 安装的 bin 目录中。

回答by Fuangwith S.

In easy way and badly style, you can copy java.exe or javaw.exe (execute file) and rename to new process name that you want.

以简单的方式和糟糕的方式,您可以复制 java.exe 或 javaw.exe(执行文件)并重命名为您想要的新进程名称。

回答by Michael Myers

I believe your best bet is to use an ahead-of-time compiler like Excelsior JETto produce an executable. As they mention, you could also use a custom laucher or wrapper instead.

我相信您最好的选择是使用像Excelsior JET这样的提前编译器来生成可执行文件。正如他们所提到的,您也可以使用自定义的 laucher 或包装器来代替。

回答by jefferycn

There are mainly 2 approaches: one is as others described: using 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,并将我们的 install|start|stop|uninstall 服务脚本中出现的每个 prunsrv.exe 替换为 MyApp.exe。

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

使用 Apache Procrun 在 Windows 中重命名 Java 程序的进程名称中查看更多信息

回答by jbilander

Old thread but if anyone still wonders...If you use the javapackagerwith the -name MyTestApp -native imageflags it will generate a native runtime image with the executable MyTestApp.exefor you and this is how it will look like in the Task Manager with the default icon:

旧线程,但如果有人仍然想知道......如果你使用javapackager带有-name MyTestApp -native image标志的它会MyTestApp.exe为你生成一个带有可执行文件的本机运行时映像,这就是它在带有默认图标的任务管理器中的样子:

task_manager_screenshot

task_manager_screenshot

Now, packaging as a Self-Contained Application may or may not be what you want. It has both benefits and drawbacks: https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#A1307236

现在,打包为自包含应用程序可能是您想要的,也可能不是。它既有优点也有缺点:https: //docs.oracle.com/javase/8/docs/technotes/guides/deploy/self-contained-packaging.html#A1307236