Solved

Any way to abort a java app running in a console gracefully?

Posted on 2004-09-20
5
263 Views
Last Modified: 2010-03-31
My program does a lot of processing. It takes a long time.

So if it is running within a windows console (command window) is there some way the user could let my application know that he wants to abort it? Like the ability to press ctrl+c, ctrl+break or something and have the java application recognize this key combo and act upon it to quit gracefully?
0
Comment
Question by:ycomp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
expertmb earned 500 total points
ID: 12109067
use addShutdownhook of Runtime.
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12109074
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12110410
The accepted answer has nothing to do with the question.

;JOOP!
0
 

Author Comment

by:ycomp
ID: 12113720
I don't know, I was reading about it and I thought that too. But then I noticed that in one of the articles it said that pressing CTRL+C would cause the console to quit and thus trigger the shutdownhook.

If you have any other ideas, let me know. thanks.
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12119810
You don't need a shutdownhook. The Ctrl/C was the right answer.
What happens next in the application is Ex Libris.

But done is done. Just realise what a shutdownhook is.

;JOOP!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question