How to run a java program in backgroud (unix / Linux)
Oftentimes, we use SSH to remote access into the server to run a Java program. The problem is, we can’t type anything After the Java program is executed like this :
$ java -jar example.jar
In addition, when the remote access session is expired or terminated, the executed Java program will be killed.
To fix it, append a
& symbol to the end of the command, it executes the Java program in the background, and continue until it finished.
$ java -jar example.jar &
If the above command get killed when you leave the SSH session, try to add
nohup in front.
$ nohup java -jar example.jar &