2 Replies Latest reply: Apr 17, 2013 2:19 AM by PhHein RSS

    Change java process name in top/ps

    843829
      JVM is running on Linux and I'm looking for an easy way to rename my running process from "java" to "myapp". The reason for this is for users to see something meaningful in "top" and "ps". An application can easly do this by writing to argv[0] - this does the trick. I'm looking for an easy way to tell the JVM to do the same. I've already tried:

      1. Starting the application via symbolic link to jre/bin/java - this works on “ps” but “top” still shows the “java”
      2. Copy java executable to another name - the JVM installation that I’m using is read only and I can’t modify it. Obviously, this also doesn’t work when the java executable is in another directory
      3. Create my own C++ code which starts up the JVM - this is the current solution that I have and there are many issues with glibc libraries. My application is running on many platforms and when linked with libjava.so it results glibc crashes when compile glibc is not the same as runtime glibc

      If I would have a way to know the address of argv[0] - I can easily do it in native code. this is also an option but I don't know how to get the address of argv[0]

      Thanks,

      Noam