在Windows上设置Java进程名称 [英] Set Java process name on Windows

查看:794
本文介绍了在Windows上设置Java进程名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Java Swing应用程序在Windows上运行,并使用Launch4J包装在exe文件中。

Our Java Swing application is running on Windows and wrapped in an exe file using Launch4J.

我们想要自定义我们的应用程序进程名称和描述(在Windows中)任务管理器)因为它当前是javaw.exeJava Platform SE binary(这对我们的客户来说很混乱)。

We would like to customize our application process name and description (in Windows' task manager) as it is currently "javaw.exe" and "Java Platform SE binary" (which is confusing for our customers).

虽然旧版本的Launch4J可以使用< customProcName> 进行更改,但此选项现已不存在,因为它在Win7中不再有效。

While older versions of Launch4J enabled to change this using <customProcName>, this option is now defunct as it is not working anymore as of Win7.

是否还有其他(简单)解决方法来自定义我们的应用程序进程名称和描述?

Is there any other (simple) workaround to customize our application process name and description?

例如,更改javaw.exe可执行文件名似乎是一种方法(因为我们将其嵌入到包装的exe文件中),但是如何指示launch4j jvm文件名更改?

For instance, changing javaw.exe executable filename seems like an approach (as we embed it in the wrapped exe file) but how then indicate to launch4j that the jvm file name changed?

另一个选项可能是创建一个启动器exe文件:可能是一个矫枉过正?

Another option could be to create a launcher exe file: maybe an overkill?

任何想法/提示都非常受欢迎;谢谢!

Any ideas / hints are more than welcome; thanks!

推荐答案

如果你想推出自己的解决方案,你会想要看看JNI和调用API ,特别是 JNI_CreateJavaVM( )用于创建VM,找到主方法 GetStaticMethodID()并使用 CallStaticVoidMethod

If you're looking to roll your own solution, you're going to want to look at JNI and the Invocation API in particular JNI_CreateJavaVM() which is used to create a VM, find the main method GetStaticMethodID() and invoke it with CallStaticVoidMethod.

这是 java.exe javaw.exe 和其他各种原生发射器在内部执行。一些例子包括:

This is what the java.exe, javaw.exe and a variety of other native launchers do internally. Some examples include:

  • OpenJDK java.c
  • IntelliJ WinLauncher.cpp
  • WinRun4J VM.cpp

如果您不想将本机构建系统与您的java构建系统集成,一种方法是提前构建一个静态 launcher.exe ,并将其视为一个静态的二进制blob。然后在您的java构建期间,使用java修改二进制blob,以更新 VERSIONINFO ,图标和启动画面。这种方法的一个例子可以在 IntelliJ LauncherGeneratorMain.java

If you want don't want to integrate a native build system with your java build system, an approach is to build a static launcher.exe in advance, and treat it as a static binary blob. Then during your java build, modify the binary blob using java, to update the VERSIONINFO, icon and splash screen. An example of this approach can be seen in IntelliJ LauncherGeneratorMain.java

这篇关于在Windows上设置Java进程名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆