I have just written a program in Java. I am curious if I can make the program downloadable online so that my friends and family can take advantage of it. No clue where to even begin.
I would like it to run locally. I am able to run the program locally on my computer by simply double clicking the .class file, I also can create a shortcut to the .class file and run it directly from my desktop. Is there a way to zip the .java file along with the .class files (there are 4 .class files) and email that to those that I wish to use it? I tried to send an email with t开发者_高级运维he zip file to another computer in the house, but the .class file wouldn't run the program on the other computer...is there another way to make this happen?
Any suggestions?
Have a look at Java Web Start:
"The Java Web Start software allows you to download and run Java applications from the web. The Java Web Start software:
- Provides an easy, one-click activation of applications
- Guarantees that you are always running the latest version of the
application- Eliminates complicated installation or upgrade procedures"
why don't you simply upload your *.jar file to a web server and let your friends download it from there? if you want the program to be embedded in a web page, you should write a java applet.
You could distribute the runnable Jar file itself, or if you're interested in making it install via the browser you could also look into java web start
If you created a web application you can host it on GAE, which is a really nice way to have online applications. If your application is a desktop java application, then just upload it on any FTP/HTTP server.
Another solution is to use the java web start style, which will allow the users to download the application and run it directly from the browser.
Resources :
- Java Web Start FAQ
- Java Web Start tutorial
On the same topic :
- What is “java web start” used for?
This is possible. Let's consider that [yourclass] is the name of the primary class (the name of the class file on which you double-click) and [appname] is whatever name you want for your application. Both are case sensitive. Just follow the next steps:
1) make a blank file with the name "manifest.mft".
2) write in manifest.mft:
"Manifest-Version: 1.0
Main-Class: [yourclass]
Class-path: .
"
3) make a blank file named "run.bat"
4) write in run.bat: "java -jar [appname].jar"
5) you first need to compile your .java file: "javac [file].java"
6) you then need to package all the class files and the manifest file in a jar file:
"jar cvfm [appname].jar manifest.mft *.class"
7) all you have to do now is to send the [appname].jar and run.bat to whom you want and all they got to do is to double click on the run.bat file to run your program. They must have JRE installed and the bin foder of the JRE in windows PATH system variable.
Unfortunately, Java is not the best language to share an app "with family and friends".
Basically, if you want them to be able to run the program, you first need to create a jar, and they need to have the JRE installed, and run it from command line.
A really good option is to use something like Launch4J which will help you create "native" executables, with an embedded JRE or a link to download it, an icon, an installer, and all that stuff that make your program look more professional and less hobby-like
精彩评论