How to deliver my Java application with a particular JRE?

前端 未结 9 1349
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 14:31

Does somebody know how to pack a particular JRE together with a compiled Java application? I currently have an executable jar file and wish to put JRE 6 Update 31 in it. So

相关标签:
9条回答
  • 2020-12-04 15:19

    This is not directly possible. To make it possible, you have to download VM's for every platform. For windows, copy the JRE to a directory and the jar and call distributed JVM by shell scripts. But this is so hard and the solution described by Cthulhu is best i.e., check the version and point to the webpage.

    However there are some you might check out.

    JSmooth - http://jsmooth.sourceforge.net/

    Jar2Exe - http://transfer2pc.weebly.com/1/post/2011/10/jar2exe-converter-11-gui.html

    0 讨论(0)
  • 2020-12-04 15:20

    On OSX, they are moving away from Apple providing Java to Oracle providing Java, this also means that Java will not be installed on a fresh install of OSX. Oracle have provided a tool for packing up Java installations and they strongly recommend providing a jre as part of your installation. The advantage of this is that the customer will not have to install an additional package in order to run your application, and you can test your application against the correct Java runtime for you and ensure there are no incomptabilities before shipping. The disavantage is that building the installer is slighty more complex and your download size is larger.

    Of course building installers get more complex if you want to provide your applications for Windows, Linux ectera and it would be alot simpler to just provide an executable jar but this is not the experience customers want. Customers do not expect to be able to download one application and run the same exe on windows, osx and linux. They are happy
    to have different installers for each platform and also expect the installers to work in a different way.

    This is how I do it:

    OSX:Use AppBundler with bundled jre, put onto a Dmg with DMGCanvas. The user simply drags the application to their /Application folder.

    Windows:Use Izpack with bundled jre wrapped with launch4j so installer can be run as an exe.

    Linux:Use Izpack without bundled jre, as user linux users like to be in control of exactly what on their machine, but specify minimum version of Java allowed. Ideally I should create packages for the main Linux Package Managers such as rpm but Ive decided this is not worth the effort at the moment as Linux users are a small percentage of my client base.

    Most of the installation is automated using Maven and Ant, so its not a big effort to build these different installers.

    0 讨论(0)
  • 2020-12-04 15:20

    You can deploy it with java webstart which enables you to download a certain version of the jre if not present. I don't know if downgrading is possible, however. Java must be installed already, too.

    0 讨论(0)
提交回复
热议问题