Archive: Java executable -- How to set the Windows process name


Java executable -- How to set the Windows process name
I scripted an installer for a java app, and I also used NSIS to create a .exe file that invokes the JRE and launches the java app, which consists of a jar file. When I launch the java launcher I see two processes in the Windows process list, one that bears the name of the java launcher executable file, and javaw.exe that represents the jre in which the java app is running. (I used ExcWait in the NSIS script to launch the java launcher, which is why it shows up alongside the javaw process.)

This makes sense, but I would like to have a single process show up in the process list. Before I discovered NSIS, I tried a wizard-based installer tool (WITEM) with java support. When I launch the app installed with WITEM, I see a single process, with the name of the executable I created (no javaw process). Judging from the memory usage of the process, I'm sure that what I'm seeing is a single native process in place of a JRE running my app.

I know there are tools out there to convert java apps to .exe apps, I assume by compiling the JRE and the java app into native code. Is that what I'm seeing with WITEM, or is there a way to get this behavior with an NSIS script?


javaw.exe doesn't really do much. Most of its job is finding jvm.dll and calling JNI_CreateJavaVM. Because it's java.exe that calls that function, the process takes its name. What WITEM probably does, is exactly what java.exe does, only with a different executable and process name. You can do the same using a plug-in you can write for NSIS.