File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Close console window with javaw Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Close console window with javaw" Watch "Close console window with javaw" New topic
Author

Close console window with javaw

Johnothan Doe
Greenhorn

Joined: Feb 27, 2004
Posts: 3
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

Joined: Feb 26, 2001
Posts: 180
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.


- Chris Stehno, SCPJ
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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 ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Close console window with javaw