This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do ordinary people run my java programs?

 
Elouise Kivineva
Ranch Hand
Posts: 154
  • 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?
 
Michael Morris
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
 
Tobi McFarland
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.....
 
Steve Deadsea
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
 
ryan headley
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic