• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAR with no Command Prompt involved

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to run my Java program without any Command Prompt windows involved, just like when you run Firefox, OpenOffice, etc. You double-click an icon and the GUI appears, and you never see a Command Prompt.

My program uses Swing for the user interface, and I have it compiled in a JAR file. I have a batch file MyApp.bat with one line:



When I double-click MyApp.bat, a Command Prompt appears just before my GUI does. It stays in the background and then disappears after I close the GUI. My program works fine, but seeing that stupid Command Prompt is really annoying.

Is there a better way to accomplish what I want without using a full-blown "installer" program? I thought using javaw instead of java to execute the JAR was supposed to keep the Command Prompt from appearing. Maybe the problem is with my batch file? I know I can use

as the first line in MyApp.bat to keep lines of output from appearing in the Command Prompt window, but is there something else I can enter to prevent the Command Prompt window itself from appearing?
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Associated the jar file type with javaw.exe.
Of course your batch file will open a command line.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are referring to Windows, as it seems, you probably would consider to use Launch4J as nice alternative.


Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables.
[...]
This program is free software licensed under the GPL license [...]

 
Bert Maki
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tony, associating the .jar file type with javaw.exe gave me the exact behavior I was hoping for!

The Launch4J program is more than I need for right now, but it looks really cool. I think I'll be giving it a try in the near future - if for no other reason initially than to learn how to use it - because it appears to add quite a bit of value and functionality. Thanks for the tip Edwin!
 
reply
    Bookmark Topic Watch Topic
  • New Topic