Skip to main content

Interrupting a running .jar file

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2008-11-08

I have a desktop java program which is executed as a .jar file. It contains many classes & screens. Is there a way to interrupt the program by pressing a key, say f1, and going to a class & when I am finished have the program restart where it left off.
Thank you,


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-06-09

It depends on what the program is doing.

First you should make sure you understand this document: Swing Concurrency.
If you've started a long-running task in the background, the user
interface will still be responsive, so you can have a key listener that
will bring up a dialog box to do whatever you want.

If you've gone off and started a long-running calculation, or a time-consuming
external access (i.e big database lookup) from a Swing event listener, then
the user interface will be hung. In this case you've really got to rewrite
the application so the long-running job is in another background thread.

It's easy to make this mistake, a lot of examples don't show this distinction,
and the result is a lot of people end up think Swing and hence Java, is slow.