This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes JRE Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JRE Question" Watch "JRE Question" New topic
Author

JRE Question

Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
I have a Java app and made a jar file from it. Now I want to deploy the app on a machine which will not necessarily have the JRE installed.
Is installation of the JRE on the client necessary or can I somehow add the JRE to my jar file and have everything the app needs in a single JAR.
That would be much better.
Thanks in advance for anybody's help here.
Rob
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Unless the JRE is already installed, the system won't know what the heck a .jar file is.
Some of the big name java installation program generators (like InstallAnywhere and friends) can optionally include a JRE that is transparently installed in the setup process.
That's about all I can say.
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Is there any way to get the JRE into the jar file without an installation program like the ones you have mentioned.
It seems like it would be something that everyone would want.
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Putting a JRE into a Jar file is trivial. A Jar file is just a zip file with a manifest. But, as David pointed out, the target machine won't know what to do with it.
--Mark
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Mark,
Thanks for your reply. I understand.
What is the preferred why to distribute a Java app? Should it be up to the user to get and install the JRE (doesn't sound good to me) or should some third party install program be used?
What is the most common method? Obviously distributing Java apps is done all the time, I just have no experience here to know the answer.
Appreciate your help.
Rob
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, some choices are:
1 - Bundle the JRE with your app. Have the user download this into a specific directory. Then create a .bat file or .sh file to invoke the app. This allows you to point to your JRE in the classpath inside the bat file. It also means that the target machine does not need a mime type set up that knows what to do with a file with a .jar extension.
2 - Buy a tool (InstallSheild is what we use) that will bundle the JRE with your app and create a self-extracting executable for the target platform.
3 - Have an Install Web Page that talks the user through doing their own download of the JRE and (for some OS's) setting up a classpath and mime type.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Originally posted by Cindy Glass:
Well, some choices are:
1 - Bundle the JRE with your app. Have the user download this into a specific directory. Then create a .bat file or .sh file to invoke the app. This allows you to point to your JRE in the classpath inside the bat file. It also means that the target machine does not need a mime type set up that knows what to do with a file with a .jar extension.
2 - Buy a tool (InstallSheild is what we use) that will bundle the JRE with your app and create a self-extracting executable for the target platform.
3 - Have an Install Web Page that talks the user through doing their own download of the JRE and (for some OS's) setting up a classpath and mime type.

Thanks Cindy!
For option #1, if I put the JRE and app into a jar file and then write a shell that sets the classpath appropriately and calls the app as follows:
java -jar app_jre.jar
How will the machine know about the "java" command?
I am still a bit confused.
Appreciate the help,
Rob
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, frankly I would just zip that stuff all together and have the user unzip it into the specified directories.
You would need to concatenate the subdirectory that will hold the java.exe into the path. Then you can just invoke the application specifying the classpath using the -cp option.
You really don't even need to use the -jar option if you fully qualify the class with the main in it.
>path .;c;\whatever;%path%
>java -cp whatever myApp myProperties.properties
Here is a .bat file that we use:
******************************************
cd \"Program Files"\myCompany\myApp
path = .;C:\"Program Files"\myCompany\myApp;C:\"Program Files"\myCompany\myApp\jre\bin;
"c:\Program Files\myCompany\myApp\jre\bin\javaw" -classpath .;"c:\Program Files\myCompany\myApp";"c:\Program Files\myCompany\myApp\myApp.jar";"c:\Program Files\myCompany\myApp\deploy.jar";"c:\Program Files\myCompany\myApp\jre\lib\rt.jar";"c:\Program Files\myCompany\myApp\jre\lib\jaws.jar";"c:\Program Files\myCompany\myApp\jre\lib\i18n.jar";"c:\Program Files\myCompany\myApp\classes12.jar";"c:\Program Files\myCompany\myApp\images" myApp.client.myAppDesktop "c:\Program Files\myCompany\myApp\myApp.properties"
************************************************
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Got it, thanks again.
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Rob, it really depends on your target audiance...
Commercial windows apps should have an installer.
Commercial Unix apps, can use installers or installer scripts.
Academic software is usually installed by hand :-p
Free software can do what it wants.
There's also the JNLP, Webstart option.

Of course, the easier you make it to install, the more people will use it.
--Mark
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Mark,
The app is for a real company and should be distributed as professionally as possible.
Seems like an installer would be the way to go for my particular situation. Which installer(s) would you recommend for both Windows, and UNIX.
Thanks,
Rob
M.K.A. Monster
Ranch Hand

Joined: May 02, 2002
Posts: 130
I think the best way is to use JavaWebStart, because the user only has to install JavaWebStart(with JRE), and then can click on a link in a website to a file, .jnlp, the only you have to understand is the jnlp syntax (very easy).
For an example look at: http://www.monster-internet.nl/javanote/
Sorry it's in Dutch, and uses XML and XSLT
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Java Web Start might be the right answer, but I would still like to hear about which installers are preferred for both Windows and UNIX.
Thanks, link in English next time would be very cool
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Still looking for input regarding the most popular installers for Java apps on both Unix and Windows.
Thanks,
Rob
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, Sun uses InstallSheild. My (rather large) company uses InstallSheild. Try running some of the installation programs that you have lying around on various CDs. You don't have to complete the installation to see who created the Install software.

InstallAnywhere is probably the other big contender.
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Sorry, I didn't check back lately. The more common ones are InstallShield and Wise. I've used Wise and liked it a lot. It's very easy to learn and use.
I've also used ZeroG's installer, but found it to have a very poor user interface.
--Mark
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
Thanks Mark.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JRE Question
 
Similar Threads
package,classpath and servlet
How to check if JRE is installed
Java Application & Registry
Java on CD-ROM
Class not found Exception?