9 Replies - 25081 Views - Last Post: 26 January 2009 - 06:45 PM Rate Topic: -----

#1 ajumatt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-October 08

Automatically Close Command Prompt Window

Posted 25 January 2009 - 07:57 PM

Well, I know this might be a noob question, but I couldn't find the answer anywhere else. My Java class instructor didn't even know the answer. I'm trying to have the black command prompt window to close automatically when I hit exit in a basic java program instead of giving me "Press any key to continue...". Is there a code or a snippet that can help me do this?
Is This A Good Question/Topic? 0
  • +

Replies To: Automatically Close Command Prompt Window

#2 Core   User is offline

  • D.I.C Lover
  • member icon

Reputation: 785
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Automatically Close Command Prompt Window

Posted 25 January 2009 - 08:01 PM

Try closing the application using this code:

System.exit(0)


Was This Post Helpful? 0
  • +
  • -

#3 ajumatt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-October 08

Re: Automatically Close Command Prompt Window

Posted 25 January 2009 - 08:05 PM

View PostCore, on 25 Jan, 2009 - 07:01 PM, said:

Try closing the application using this code:

System.exit(0)



I have that, but it's not working...
I also tired setDefaultCloseOperation(EXIT_ON_CLOSE);
It closes the program, but then I have to press another key to close the command prompt window...
Was This Post Helpful? 0
  • +
  • -

#4 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 552
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

Re: Automatically Close Command Prompt Window

Posted 25 January 2009 - 08:08 PM

Ummm...I don't know of any way to do that while your application is not in a stand-alone executable form. As a matter of fact...I don't believe there is a way.

This post has been edited by Locke: 25 January 2009 - 08:09 PM

Was This Post Helpful? 0
  • +
  • -

#5 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:19 PM

What about:

getRuntime().exec("EXIT");
Was This Post Helpful? 0
  • +
  • -

#6 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 552
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:21 PM

View Postpbl, on 26 Jan, 2009 - 07:19 PM, said:

What about:

getRuntime().exec("EXIT");


If that's anything like the C++ function system(...);, then that could have unexpected consequences. I don't know if it is or not, but just a heads up.
Was This Post Helpful? 0
  • +
  • -

#7 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:27 PM

View PostLocke, on 26 Jan, 2009 - 05:21 PM, said:

View Postpbl, on 26 Jan, 2009 - 07:19 PM, said:

What about:

getRuntime().exec("EXIT");


If that's anything like the C++ function system(...);, then that could have unexpected consequences. I don't know if it is or not, but just a heads up.

Worthes a try
Was This Post Helpful? 0
  • +
  • -

#8 ajumatt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-October 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:33 PM

Thanks for your repliesand support guys... I believe there is no way to do it then... Thanks for all your help again.
Was This Post Helpful? 0
  • +
  • -

#9 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 552
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:34 PM

View Postajumatt, on 26 Jan, 2009 - 07:33 PM, said:

Thanks for your repliesand support guys... I believe there is no way to do it then... Thanks for all your help again.


Did you try pbl's suggestion?

Runtime.getRuntime().exec("EXIT");


It might work, it's at least worth a shot.
Was This Post Helpful? 0
  • +
  • -

#10 ajumatt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-October 08

Re: Automatically Close Command Prompt Window

Posted 26 January 2009 - 06:45 PM

Did you try pbl's suggestion?

Runtime.getRuntime().exec("EXIT");


It might work, it's at least worth a shot.
[/quote]

yeah, I tried tha, but it's giving me more problems. 100% of people I talked to said that it's impossible, so I'm going to stick with their answers.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1