File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How do ordinary people run my java programs? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do ordinary people run my java programs?" Watch "How do ordinary people run my java programs?" New topic

How do ordinary people run my java programs?

Elouise Kivineva
Ranch Hand

Joined: Feb 07, 2002
Posts: 154
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?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Tobi McFarland

Joined: Nov 26, 2001
Posts: 10
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.....

Tobi<p>Aspiring Java Jedi
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
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:
If you want to see an example, you can use a game I wrote that is packaged in a jar file:
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

Joined: Nov 26, 2001
Posts: 10
Thanks for the info Steve :-D
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
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.

Ryan Headley<br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: How do ordinary people run my java programs?
It's not a secret anymore!