Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Quit program that is running in command shell

Reply
Thread Tools

Quit program that is running in command shell

 
 
Java and Swing
Guest
Posts: n/a
 
      09-11-2006
I have a Java app that is compiled into a JAR file. I then execute the
program from the command line (on windows xp) like this:

c:> java -jar MyApp.jar

.....works fine. Then at some point I want to quit the app by pressing
Ctrl + C....but it doesn't shut down. Now, the application has several
threads running....which have a "stopThread" method which I need to
call, but I need to know when to call them. i.e. how do I know the app
is trying to shutdown so that I can kill the threads?

thanks

 
Reply With Quote
 
 
 
 
jiji
Guest
Posts: n/a
 
      09-11-2006

> how do I know the app is trying to shutdown so that I can kill the threads?


Attach ShutdownHook to ur application...

http://java.sun.com/j2se/1.4.2/docs/...va.lang.Thread)
http://www.roseindia.net/javatutoria...own_call.shtml

Jiji

 
Reply With Quote
 
 
 
 
Java and Swing
Guest
Posts: n/a
 
      09-11-2006
Thanks, I added a shutdownhook to the runtime, in there I stop all
threads and call Runtime.getRuntime().halt(1);

works great.

 
Reply With Quote
 
Fred Kleinschmidt
Guest
Posts: n/a
 
      09-11-2006

"jiji" <> wrote in message
news: oups.com...
>
>> how do I know the app is trying to shutdown so that I can kill the
>> threads?

>
> Attach ShutdownHook to ur application...


What's an ur application? Ur hasn't been around since Biblical times.
>
> http://java.sun.com/j2se/1.4.2/docs/...va.lang.Thread)
> http://www.roseindia.net/javatutoria...own_call.shtml
>
> Jiji
>



 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      09-11-2006

"Fred Kleinschmidt" <> wrote in message
news:...
>
> "jiji" <> wrote in message
>>
>> Attach ShutdownHook to ur application...

>
> What's an ur application? Ur hasn't been around since Biblical times.


U.R. Application:
http://www.chem.rochester.edu/Gradua...tructions.html

- Oliver

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Best command for running shell command Donald Duck Python 3 07-11-2006 03:05 PM
Run Unix shell command $ parse command line arguments in python rkoida@yahoo.com Python 4 04-23-2005 04:42 AM
running a shell command from a python program Sandman Python 4 02-23-2005 06:25 PM
can I run unix shell command in the ModelSim shell? clinton__bill@hotmail.com VHDL 2 02-18-2005 10:04 PM



Advertisments