3

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 4

6

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
1

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.

1

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.

1
  1. Use the options to ps that let you see the parameters (i.e. main class name)

  2. Create a softlink to java.exe, with the name you desire, and use that to run the program. (untested)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .