Quit program that is running in command shell

Discussion in 'Java' started by Java and Swing, Sep 11, 2006.

  1. 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
     
    Java and Swing, Sep 11, 2006
    #1
    1. Advertising

  2. Java and Swing

    jiji Guest

    jiji, Sep 11, 2006
    #2
    1. Advertising

  3. Thanks, I added a shutdownhook to the runtime, in there I stop all
    threads and call Runtime.getRuntime().halt(1);

    works great.
     
    Java and Swing, Sep 11, 2006
    #3
  4. Fred Kleinschmidt, Sep 11, 2006
    #4
  5. Java and Swing

    Oliver Wong Guest

    Oliver Wong, Sep 11, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    5,850
    Jonathan Bromley
    Feb 18, 2005
  2. Sandman
    Replies:
    4
    Views:
    944
    aurora
    Feb 23, 2005
  3. Brandon
    Replies:
    0
    Views:
    359
    Brandon
    Nov 26, 2005
  4. Donald Duck

    Best command for running shell command

    Donald Duck, Jul 11, 2006, in forum: Python
    Replies:
    3
    Views:
    425
    iapain
    Jul 11, 2006
  5. K Viltersten

    Quit-command not quiting

    K Viltersten, Mar 7, 2008, in forum: Python
    Replies:
    4
    Views:
    493
    K Viltersten
    Mar 9, 2008
Loading...

Share This Page