Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Close console window with javaw

 
Johnothan Doe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that if you use javaw instead of java to call your program from a bat file you can close the console window manualy and the JVM will still keep your application open. What I want to know is if there is a way to either in the bat file or the application to automaticaly close that console window once the application is started. Thank you in advance.
 
Chris Stehno
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am guessing that you are running under Windows 2000 or XP (I think XP does the same thing). There is a bug(?) in javaw for those platforms that does not close the console window -- as you have seen. The only way that I know of to get around that is to run your app from a jar file using 'javaw -jar ...'. Running from a jar file does not keep the window open.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure that this would work on all versions of Windows. It works on Windows XP Professional.
In your bat file, you could invoke javaw as follows.
start javaw Foo
But note that a more platform independent strategy would be to create an executable JAR, as Chris mentioned.
[ February 28, 2004: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic