Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

how to change the name of a Java application process?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...