开发者

Is there a mechanism to distribute an app with its own JRE?

开发者 https://www.devze.com 2022-12-28 01:01 出处:网络
These fine folks are my users: http://www.youtube.com/watch?v=o4MwTvtyrUQ If you don\'t want to enjoy the video here is the gist: my users can\'t tell between a file and a folder, between a browser a

These fine folks are my users: http://www.youtube.com/watch?v=o4MwTvtyrUQ

If you don't want to enjoy the video here is the gist: my users can't tell between a file and a folder, between a browser and a web site.

I need to create a Java web app (Tomcat or Jetty) and deploy it in as many of their computers, Windows and Mac.

The question is: Is there a mechanism to dis开发者_运维技巧tribute an app with its own JRE? (in the Tcl world there are starpacks and starkits, in the Python world there's py2exe and others, that's the idea). And also, is it legal? I know the VM is open source but I'm not clear about the libraries, and I know about GNU Classpath but I don't know if all the packages are there.

I don't want to depend on the installed JRE or on the user having enough privileges to install one. On the Mac I don't want to depend on Apple (I had to switch from Tiger to Snow Leopard just to have Java 1.6, I can't put my users in that position)

Any info greatly appreciated. Thanks! jb

edit: I'm wondering if I can just paste the JRE folder under my app folder. Is that allowed?


We use Install4j at our workplace. It takes care of installation and installs the JRE if needed too. Its not free though. And at least the version we use doesn't provide Mac users with a bundled JRE. But as far as I was able to find out, that was due to some restrictions by Apple. Macs come with their own JRE and if your user has a Mac, its safe to assume they have a JRE installed. Although, if the JRE is an older version than the one you like, then they would have to use Software Update to check if a newer version is available and install it.


    To run your application, a user needs the J2SE Runtime Environment,
    which is freely available from Sun. Or, You can redistribute the 
    J2SE Runtime Environment for free with your application, according 
    to the terms of the Runtime Environment's license.

From http://java.sun.com/j2se/1.5.0/jre/README

I haven't read the fine print, it seems that Sun intends for people to redistribute the JRE. Also, there are many products (e.g. install4j) that make it easy for you to redistribute the JRE, so it seems to be legal.

As to the rest of it, you could then also bundle tomcat, with the built in Service so your app is automatically started, and create a shortcut on the desktop to your local webapp, so users are freed from typing ht tp://localhost:8080/webapp. There are plenty of FOSS installers (e.g. izpack) that will allow your users to install the package, and manage creation of desktop shortcuts. You mentioned preferring not using an installer, but even unzipping is kind of installing - your users have to choose a directory that they have write access to, and this is no different with a fully fledged installer.

But, given the capabilities of your users, is a locally installed solution the most suited to them? An online solution might offer simpler deployment (e.g. Java web start, or even as an applet.)


In OS X you pretty much are stuck with whatever Apple provides you. In other platforms, it is not needed to run a JRE installer (which you correctly point out your users may not be able to do), just bundle a JRE folder alongside your app. That is what many of our users do (my company has a multiplatform installer called InstallBuilder) and we have packaged many Java web apps that way. You can take a look at some of them at BitNami (they are all free)


Or in short, you can try this:

Make a self executable jar file of your app.

  • Provide your users small JRE setup (appx 15MB for jre6u7) along with your app.
  • Now create a batch file(for windows) which will first execute the JRE installer.
  • Then select path to installed JRE's 'bin' folder.
  • Now after this write 'java -jar yourAppName.jar' in the script to run your executable jar file.

eg: for win.bat write the following:

jre-6u7-windows-i586-p  :: this will start the JRE installer
C:\Program Files\Java\jre1.6.0_07\bin\java -jar yourAppName.jar  :: this will start your app

You can create such scripts for Mac and Linux also.

0

精彩评论

暂无评论...
验证码 换一张
取 消