Java, Eclipse: How do I pause a running program?

5,549

Since you mentioned you're running Linux, you can use the kill command with the -STOP and -CONT arguments might be a more appropriate option to pause and resume the process.

First, open a terminal and get the PID using

ps aux

Then run

kill -STOP pid

where pid is the PID of your Java process.

To resume, run

kill -CONT pid

Brief tutorial here: http://tombuntu.com/index.php/2007/11/23/how-to-pause-a-linux-process

Another method would be to run your program in debug mode in Eclipse and pause it in the Debug view. However, running in debug mode will incur a nasty performance hit.

Note that the network connection in your program will probably need to be reopened (either due to changing networks or due to your connection getting closed due to timeout out on the other side), so you'll have to code some logic to detect a dropped network connection and reconnect.

Share:
5,549

Related videos on Youtube

Legend
Author by

Legend

Updated on September 17, 2022

Comments

  • Legend
    Legend over 1 year

    I am running some computation on my Linux box and can't really afford to run it on battery while I drive home. It requires a network connection and currently I am running this stuff on a wireless connection. After reaching home, I need to hook up an ethernet cable to get the Internet.

    I've never done this before but I want to "resume" the computation after reaching home. For that, I am thinking that I should suspend the eclipse program (which apparently I did not start from a terminal, so how would I suspend it?), put the system into standby. Then get the system out of standby, connect the ethernet cable, get a new IP address, then resume eclipse. I am assuming it will work.

    Anyone has a better approach?

  • Legend
    Legend over 14 years
    This is on my linux box by the way...