Continue execution in console after running jar
*Note:*I currently trying to do this in linux console which i access with putty.So please consider this in your answer
Thank you
java -jar myJar.jar &
The &
puts the command into the background and allows you to do other things from the shell prompt.
This is very basic UNIX/Linux shell stuff. I suggest that you find / read an online tutorial or a book on the shell you are using (e.g. bash). It will make your life a lot easier. Or if you are a masochist, read man bash
.
I currently trying to do this in linux console which i access with putty.
Use of putty is actually not relevant.
Try this
java -jar myJar.jar&
It means that the process gets launched and runs in the background. If you want to get it back, type fg
. To push it back in the background, press CTRL+Z (this pauses its execution and gives you back your shell prompt) and then run bg
to resume it in the background.
Just run it as
java -jar myJar.jar &
The &
will put the command into the background, where it happily runs. Just a basic Unix shell feature.
I personally prefer using screen. Because you can even define a session ID and restore them really easy.
You can start the jar with the following command:
screen -m -d java -jar myJar.jar
With the following command you can list all current sessions:
screen -ls
You can reopen a session with:
screen -r PID/Sessionname
Undeleted this answer after the OP last comment - it's not an answer to the written question but an additional answer to his actual problem
On windows, try
start java -jar myJar.jar
Reference: MS-DOS start command
精彩评论