如何更改Java应用程序进程的名称? [英] how to change the name of a Java application process?

查看:487
本文介绍了如何更改Java应用程序进程的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行Java应用程序时,给它的进程名称通常是 java.exe javaw.exe 。但是如何通过我的应用程序名称来调用它?

When executing a Java application the process name given to it is usually java.exe or javaw.exe. But how can I make it be called by the name of my application?

推荐答案

这些方法适用于具有大量服务器的服务器java进程正在运行,你需要快速找到正确的jvm(不使用jps)。对于应用程序,我认为launch4j或其他包装器是可行的。

These methods are suited for servers with a lot of java processes running, and where you need a quick way of finding the correct jvm (not using jps.) For applications, I suppose launch4j or another wrapper is the way to go.

在unix上,如果你从shell sript(至少对于bash和可能用于其他体面的shell)启动你可以使用:

On unix, If you are launching from a shell sript (at least for bash and possibly for other decent shells) you can use:

exec -a goodname java ...

启动 java 并传递goodname作为第0个参数,它将在 ps 等中显示为进程名称。

to launch java and pass "goodname" as the 0th argument, which will be shown as the process name in ps etc.

一个更好的选择(似乎也适用于 top )是创建一个符号链接: ln -s / usr / bin / java / usr / local / bin / kallekula

A perhaps better alternative (that seems to work also for top) is to create a symlink: ln -s /usr/bin/java /usr/local/bin/kallekula.

Windows中的快捷方式不起作用,但是windows vista / 7支持使用 mklink 的符号链接。这可能有用,但我还没有测试过。我不确定 exec -a 是否也适用于Windows上的cygwin bash。

Shortcuts in windows won't do the trick, but windows vista/7 supports symlinks using mklink. That may work, but I haven't tested. I am not sure if exec -a also works with cygwin bash on Windows.

这篇关于如何更改Java应用程序进程的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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