tags:

views:

2133

answers:

6

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?

+6  A: 

Check out launch4j, it is an executable wrapper that allows you to assign executable names.

yx
+4  A: 

Unless you launch Java via JNI in your own custom built executable, the process name will always be java.exe.

There are several java launchers/wrappers that can generate this executable for you.

basszero
A: 

If you're using the Sun JDK, you can also use the "jps" command line tool to get a detailed list of Java processes running on the box.

Rob H
+2  A: 

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.

KarlP
This is good for launching servers etc, as it is a simple edit in the start shell-script.
KarlP
A: 

Assuming that what you are really after is a way to terminate the correct the correct process later on, then an alternative solution is this:

Run ps-ef and you should get a listing that looks something like this:

mruser 7518 7505 4 11:37 pts/3 00:00:00 /usr/lib/jvm/sun-jre-bin-1.5/bin/java -classpath MRD3030_Linked.jar peralex.MyApp

Then "pkill -f peralex.MyApp"

will kill the correct process.

Noel Grandin
A: 

Not all flavors of exec support the -a flag. If yours doesn't, the argv0 program does something similar.

mpm