Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 23909
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic