How to rename java process? [duplicate]
Possible Duplicate:
How to rename java.exe/javaw.exe process?
Hi,
I am working on java desktop application. When the program starts, it creates a process java.exe
. I have not been bother about this. But now, o开发者_StackOverflow中文版ne of my user want this process name to be changed to <project-name>.exe
.
So, Please provide me some suggestions, how can I achieve this feature for my program?
By nature, Java programs are usually interpreted by a JVM. The Java process you see is that JVM instance in fact.
To make what you want, you have to encapsulate the JVM in your own program so that you have apparently only one executable (and no JVM dependencies for your users).
I recommend you to have a look to these free projects:
- http://jsmooth.sourceforge.net/
- http://launch4j.sourceforge.net/
Doing a query like "java to exe" in Google can also helps to find the latest news. Looking into gihub could also help to find latest tools.
Note that if you do that, you loose one nice feature of Java which is cross-platform portability.
There are alternatives like JNLP and others.
You also can have a look to this good article
A really simple way would be to make a copy of java.exe (or javaw.exe) under the name you want, and call this instead of java(w).exe
Something I have seen is that you could create your own executable file which in turns launches your Java application as a child process; you can name your executable file as you wish. Your parent process will wait until the child process returns (it is killed or finished), additionally you could add some logic so that if the parent process is terminated, the child process will also be terminated (but this could be tricky to implement and may not work for a hard abort or SIGKILL).
The big problem with this solution is that you will have to create code that is platform independant.
精彩评论