java服务进程名,如何更改Java应用程序进程的名称?

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?

解决方案

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.

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

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

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值