• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

How do ordinary people run my java programs?

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I've written something fun and/or useful how to I package it so an computer beginner can run it? This kind of person won't want to install & confige the jdk and probably couldn't handle the command line anyway.
Isn't there something like a windows shortcut?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elouise,
Have you ever heard of a batch file? It's Windows (actually it comes from the days of DOS) version of a UNIX shell script. You may be familiar with a file in the root of the Windows host drive named "Autoexec.bat", which is a batch file that runs at boot time. You can set variables (like CLASSPATH), make flow-of-control choices and execute programs (like java.) Anyway you probably should package your program in a jar file which can be made executable. That way you could start your program with a dialog to capture what you have set up as command line parameters. Then the user can simply double-click the jar file just like any other program.
Hope this helps
Michael Morris
SCJP
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know of a tutorial that helps explain how to package java programs as executable batch files? I've always wanted to know the specifics of how this is accomplished.....
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer using jar files. Most users can double click on them to start your program. They do require that the user downloads the JRE.
There is a tutorial on how to use jar files at:
http://java.sun.com/docs/books/tutorial/jar/
If you want to see an example, you can use a game I wrote that is packaged in a jar file:
http://ostermiller.org/ladder/
Another way would be to write an applet. An applet can be run in a web browser and most web browsers have some sort of Java installed. Java Webstart can also be used for this purpose. Be aware that such programs run in a security sandbox.
Also there are commercial installers that will package your java application along with a runtime environment. Makes it easy on the user but takes the download up several megabytes and can be expensive.
 
Tobi McFarland
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info Steve :-D
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I setup a shortcut to the jar file and have no black dos box either.
I simply use javaw.exe -jar jarfile as the target rather than java.exe -jar jarfile.
works like a charm every time.
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic