简体   繁体   English

将JRE与Java应用程序捆绑在一起

[英]Bundling the JRE with a Java application

I have created an exe with a launch4j Ant script and build.xml file. 我用launch4j Ant脚本和build.xml文件创建了一个exe。 I want to bundle the JRE in my application and have to distribute it to clients. 我想在我的应用程序中捆绑JRE并将其分发给客户端。 How do I do this? 我该怎么做呢?

Thanks, Rajani 谢谢,拉贾尼

Well, just bundle everything under $JAVA_HOME/jre into your distribution (presumably a Zip / TAR file) and then have your scripts reference that (ie use the java executable under $JRE_HOME/bin to run your java program). 好吧,只需将$JAVA_HOME/jre下的所有内容捆绑到您的发行版(可能是Zip / TAR文件)中,然后让您的脚本引用它(即使用$JRE_HOME/bin下的java可执行文件来运行您的java程序)。

Remember that if you do this, you will have to deliver different distributions for different target platforms (Windows,OSX, linux etc) and architectures (or one bloated uber-distribution of course, but no one will thank you for that!). 请记住,如果你这样做,你将不得不为不同的目标平台(Windows,OSX,linux等)和架构提供不同的发行 (当然,或者一个臃肿的超级发行版 ,但没有人会感谢你!)。

This works great... if you want your program to run on just a single version of a specific OS. 这非常有用......如果您希望程序只在特定操作系统的单个版本上运行。

Generally, though, bundling a JRE is a bad idea. 但一般来说,捆绑JRE是一个坏主意。 Even on Windows, there are three versions of the JRE: one for x86, one for x86-64, and one for Itanium. 即使在Windows上,也有三个版本的JRE:一个用于x86,一个用于x86-64,一个用于Itanium。 Even if Sun does make it hard to find the 64-bit versions, they still exist. 即使Sun确实很难找到64位版本,它们仍然存在。

The 64-bit versions of Java for Windows are actually on java.sun.com , but not java.com. 用于Windows的64位版本的Java实际上是在java.sun.com上 ,而不是java.com。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM