Run Jar in Background on Linux

several ways:

  1. appending & at the back. However, using this, the program will still be terminated if you closed the terminal that started the program.

  2. Start a screen session, and start the program inside it; you can detach the screen session and close the terminal. Later on, you can attach to the session again and found yourself back on the console as if you've been there all along. However, you will need to start a screen session before running the program, and if you forgot to do that, you can't do anything about it.

  3. Use disown job control from your shell. This will detach the task from your tty and your program won't be terminated when the tty is closed. However, I don't think there's any way to reattach a disowned job.


A command line prompt I have always used for long run times to last through logoffs is "nohup" so in your case is

nohup java -jar test.jar &

The & is important so you can get another shell running. I believe this will not last through reboots.