• 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

Launching a Java app from the desktop.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy
I am trying to find out how to launch my Java app from an icon on the desktop.
So far I have the icon that links to a .bat file. However the command line box still stays open even though I put the exit command in the .bat file:-
java myapp
exit
Does anyone know how to do this and is this the best way of launching java files?
Adam
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm . . my DOS boxes all close when I exit my Java app and we do not use the exit command in the .bat file. We also just hook the icon to the .bat file.
Are you using System.exit(0); when you are leaving your app?
What version of Windows are you using?
 
Adam Till
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows XP. I dont have the System.exit bit in yet just opening a simple form, what I was trying to do was have the DOS box close as soon as the app begins to run.
Is this possible or does it always stay open?
Thanks for your reply by the way.
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using javaw instead of java in the shortcut.
javaw myapp
it will launch the app without launching the console window (i assume your program is a gui).
you might have to add the classpath as an option to the command.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run this fir all my apps
<path to >\javaw.exe -jar <path to>/app.jar
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javaw.exe no longer leaves out the DOS box. There were just TOO many issues with not having a place to write error messages to. You might remember this as you try to do without it.
All of our apps leave the DOS window open but minimized (you can set that in your icon).
What javaw does now is allow the user to close the window after it comes up.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lose the .BAT file, just create an executable JAR file and double click on it.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But then, of course, you can not use a different classpath than the user normally does.
And you can not set a different Path on the fly.
And you can not include parameters when you fire up your app. For instance - it sure does make it alot easier if you can take in the name of your properties file as a parameter. The file can then stay editable outside the jar file etc.
[ October 11, 2002: Message edited by: Cindy Glass ]
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't use a batch file or an executable jar. I have been using something similar to this for some time now. I haven't had any problems with path/classpath issues, incorrect JRE's being used (assuming you bundle your Java app with a JRE, which you should), etc., since I started using it.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well for actual distribution we bundle everything up using InstallSheild. We just put an install executable on a web page. The user downloads it, double clicks that, and everything self installs for you, and puts an icon on the desktop for you.
All the end user does is click an icon.
I don't see the advantage of this product. The only thing that it saves it writing 3 lines of .bat file code. And you STILL have to tell that information to this Launcher - so no savings at all.
 
John Smith
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


All of our apps leave the DOS window open but minimized (you can set that in your icon).


Don't your users find this annoying? I know I would. Using a C++ launcher program to get rid of DOS windows is one advantage over batch files. Also, if you don't mind dabbling in C++, you can modify the launcher (or create your own - it's very few lines of code) to display a splash screen, or do other OS/machine specific things. The nice thing about the splash screen is that it displays immediately since it doesn't have to wait for Swing/AWT to load.
 
Jon Dornback
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
amazing how a detail like this can really detract from a language. i wish sun would come out with a better solution.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Coming up with a better solution would take away the write once, run anywhere philosophy that Sun has tried so hard to adhere to. If they were to provide you ways to distribute your application beyond what they already have, they would have to provide those methods for each platform and supply them seperatly.
That's why InstallShield exists, Batch files, Shell Scripts, etc. So you have options, but Sun doesn't have to worry about them.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I launch my own Java apps from the desktop all the time, one Iv'e got is called JScratchPad...
In my runScratch.bat the line to launch the java app (once setting of paths etc is done) is:
start "JScratchPad" "%JAVA_HOME%\bin\javaw.exe" -ms16m -mx20m -cp "%CLASS_PATH%" %APP_CLASS% %*
The start is the Windows/DOS command to run without a Dos window and javaw is the Java window-less startup command. I use both because I and my colleagues have had problems with just using one.
Have fun...
Matt.
reply
    Bookmark Topic Watch Topic
  • New Topic