Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 5 down vote accepted

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
share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
  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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.