Is it possible to run a Java process in Linux in a way that it could be seen in ps
as some sort of alias? It would be easier to restart it when it is down.
4 Answers
Try Java Virtual Machine Process Status Tool(
jps)
:
[Tue Aug 30@17:02:14][prince@localhost ~]$ jps -l
30207 sun.tools.jps.Jps
29947 org.netbeans.Main
Here is a description of how to change the program name.
It is done by changing the first program argument argv[0]
, which contains the program name. This makes it necessary to write a small wrapper around the Java binary.
Restarting a program when it is down could be done very differently. For example:
#!/bin/bash
jstart () {
java -cp /foo/bar baz.Main
jstart
}
Start your script, and if the program terminates, it gets restarted immediately.
You have to hit Ctrl + C to terminate your script, or kill the script by name.
Use the options to
ps
that let you see the parameters (i.e. main class name)Create a softlink to
java.exe
, with the name you desire, and use that to run the program. (untested)