jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Opening .jar from .bat shortcut... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Opening .jar from .bat shortcut..." Watch "Opening .jar from .bat shortcut..." New topic

Opening .jar from .bat shortcut...

Primoz Karnekaj

Joined: Apr 19, 2009
Posts: 5
I made a program in NetBeans and everything is working OK.
I created a .bat file, which opens the .jar program correctly, but also opens a "cmd window" next to .jar program.

This is in the .bat file:

This does the same thing:
java -jar "folder\program.jar"

Now I am wondering how one could open this .jar program itself without cmd window next to it, using a .bat file or some other shortcut? Are there any flags like -nocmd..

Henry Wong

Joined: Sep 28, 2004
Posts: 20370

I think the "javaw" command should work here...


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Primoz Karnekaj

Joined: Apr 19, 2009
Posts: 5
javaw is not wroking, unless i'm doing something wrong..

Here is the screenshot to make thing clearer

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The terminal you see is the one that the Batch file is executing in. In order to get rid of it you need to tell Windows to start the application in a 'new' window/terminal. You do this with the START command:

Primoz Karnekaj

Joined: Apr 19, 2009
Posts: 5
Thank you very much for helping me out, it works perfectly!

It is sorta covered in the JavaRanch Style Guide.
subject: Opening .jar from .bat shortcut...
It's not a secret anymore!