Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

keep cmd window open after System.exit(0) (.bat file)

 
Jorg Klein
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open a command window and then run the .bat file from there.
 
Jorg Klein
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21117
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jorg Klein
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic