| Author |
keep cmd window open after System.exit(0) (.bat file)
|
Jorg Klein
Ranch Hand
Joined: Feb 13, 2006
Posts: 33
|
|
Hello, I made a program and I run it with a .bat file. This works fine but if my program crashes and it does a System.exit(0) the cmd screen closes at once. I can't read the exception message thats printed on the cmd. How can I make sure the cmd stays open? I already tried running with java instead of javaw, that doenst solve the problem. Regards, Jorg Klein
|
Learning for SCJP 1.5!!!
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
|
Open a command window and then run the .bat file from there.
|
Joanne
|
 |
Jorg Klein
Ranch Hand
Joined: Feb 13, 2006
Posts: 33
|
|
Originally posted by Joanne Neal: Open a command window and then run the .bat file from there.
I also already tried that but the .bat file was not visible from the command window for some strange reason. If I looked in the dir with dir/p or dir I did not see my .bat file, very strange
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Originally posted by Jorg Klein: I also already tried that but the .bat file was not visible from the command window for some strange reason. If I looked in the dir with dir/p or dir I did not see my .bat file, very strange
That is incredibly strange... Maybe you were in the wrong location. Anyway, another option is to have your batch file start yet another command window -- one that will stay around. In your batch file, do something like... cmd /k java ... Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Jorg Klein
Ranch Hand
Joined: Feb 13, 2006
Posts: 33
|
|
finally, that works Henry! start "ApplicationName" cmd /k "%JAVA_HOME%/bin/java" -cp ..... that works!! thanks a lot! I searched a long time for a solution!
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
You can use the "pause" command to block a bat file and optionally display a message like "Hit any key to continue, any other key to quit." Hmmm, just tried it an it doesn't take an optional message. Maybe that was OS/2. [ March 03, 2006: Message edited by: Stan James ]
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: keep cmd window open after System.exit(0) (.bat file)
|
|
|