如何在安装程序中正确重新打包JRE安装程序?

时间:2021-03-18 07:23:04

I've got a Java application that I'm writing an installer for. We're using the AdvancedInstaller program to create our installer (well, we're evaluating it currently, but will definitely purchase a license soon), and although it has special support for Java applications, it is geared more towards repackaging them as desktop-type apps, and our software is a series of Java services and other utilities which doesn't make sense to distribute in EXE-wrappers. The target audience for this software is very specific, and we know that our software will probably be automatically distributed on freshly-imaged Windows 2003 Server machines. So requiring Java as a prerequisite basically makes more work for some poor sysadmin, and I'd rather avoid that if at all possible by repackaging the JRE's installer inside of our own.

我有一个Java应用程序,我正在编写安装程序。我们正在使用AdvancedInstaller程序来创建我们的安装程序(好吧,我们目前正在评估它,但肯定会很快购买许可证),虽然它对Java应用程序有特殊支持,但它更倾向于将它们重新打包为桌面 - 类型应用程序,我们的软件是一系列Java服务和其他实用程序,在EXE-wrappers中分发是没有意义的。该软件的目标受众非常具体,我们知道我们的软件可能会自动分发到新映像的Windows 2003 Server计算机上。所以要求Java作为先决条件基本上可以为一些不良的系统管理员做更多的工作,而且如果可能的话,我宁愿通过重新打包我们自己的JRE安装程序来避免这种情况。

I discovered that if I tried to execute the JRE's installer as a pre-install step from my MSI, it complains that another installer is already running (mine, of course), so it bails out. When I try to add the JRE installer as a software prerequisite in the AdvancedInstaller project (as a bundled EXE, not a URL link), it never seems to actually get installed, despite me trying to force-install it.

我发现如果我尝试从我的MSI执行JRE的安装程序作为预安装步骤,它会抱怨另一个安装程序已经在运行(当然是我的),所以它很难解决。当我尝试将JRE安装程序添加为AdvancedInstaller项目中的软件先决条件(作为捆绑的EXE,而不是URL链接)时,尽管我尝试强制安装它,但它似乎从未实际安装过。

What's the best way to repackage the JRE? I'm not really a Java guy, so I don't know too much about how other developers deal with this same problem, short of requiring their users to hunt out and install the JRE on their own. The ideal solution here would be for us to find a EXE installer which can be executed from inside of another MSI installer, or if it's possible, to just package all of the files inside of the JRE and then create the appropriate registry and environment variables. How should I go about doing this?

重新包装JRE的最佳方法是什么?我不是一个真正的Java人,因此我不太了解其他开发人员如何处理同样的问题,而不是要求用户自己寻找并安装JRE。这里的理想解决方案是让我们找到一个可以从另一个MSI安装程序内部执行的EXE安装程序,或者如果可能的话,只需打包JRE中的所有文件,然后创建相应的注册表和环境变量。我该怎么做呢?

3 个解决方案

#1


2  

I agree with bdumitriu's answer:

我同意bdumitriu的回答:

a simple zip of a jre is enough, unless you want to link that jre to:

一个简单的jre拉链就足够了,除非你想把这个jre链接到:

  • default java (meaning you must add java.exe of the unzipped jre to the path, before any other java path references)
  • default java(意思是你必须在解压缩jre的路径之前添加java.exe)

  • default java for some script (you could define JAVA_HOME as referencing your new unzipped jre, but that may have side effects on other script also using JAVA_HOME before that new JRE)
  • 某些脚本的默认java(您可以将JAVA_HOME定义为引用新的解压缩jre,但在新JRE之前也可能使用JAVA_HOME对其他脚本产生副作用)

  • file associations like .jnlp or .jar files (this requires some registry modifications)
  • 文件关联,如.jnlp或.jar文件(这需要一些注册表修改)

  • browser java plugin registration (which requires also registry modifications)
  • 浏览器java插件注册(也需要注册表修改)

If the last two points do not interest you on the desktop concerned by this deplyment, a simple zip is enough.

如果最后两点对您所关注的桌面不感兴趣,那么简单的拉链就足够了。

#2


4  

I have not idea if this is "the way" to do it, but confronted with a somewhat similar problem, we simply archive an installed JRE with the rest of our application files and make sure that all our start scripts don't use java ..., but rather ..\..\jre\bin\java ... or similar. The JRE is unpackaged as part of our installation process in a subdirectory of where we install and that's that.

我不知道这是否是“方法”,但面对一个类似的问题,我们只是将已安装的JRE与其余的应用程序文件存档,并确保我们所有的启动脚本都不使用java。 ..,而是.. \ .. \ jre \ bin \ java ...或类似的。作为我们安装过程的一部分,JRE在我们安装的子目录中解压缩,就是这样。

#3


1  

http://www.syswow64.co.uk/2013/05/java-7-update-21-1721-enterprise.html

The issue on many blogs and articles is around creating the 'deployment.config' and 'deployment.properties' files for an enterprise deployment. In my case i wanted to set the security level to 'Medium', but everytime I open the Java control panel it was set to the default HIGH setting.

许多博客和文章的问题在于为企业部署创建“deployment.config”和“deployment.properties”文件。在我的情况下,我想将安全级别设置为“中”,但每次打开Java控制面板时,它都设置为默认的HIGH设置。

#1


2  

I agree with bdumitriu's answer:

我同意bdumitriu的回答:

a simple zip of a jre is enough, unless you want to link that jre to:

一个简单的jre拉链就足够了,除非你想把这个jre链接到:

  • default java (meaning you must add java.exe of the unzipped jre to the path, before any other java path references)
  • default java(意思是你必须在解压缩jre的路径之前添加java.exe)

  • default java for some script (you could define JAVA_HOME as referencing your new unzipped jre, but that may have side effects on other script also using JAVA_HOME before that new JRE)
  • 某些脚本的默认java(您可以将JAVA_HOME定义为引用新的解压缩jre,但在新JRE之前也可能使用JAVA_HOME对其他脚本产生副作用)

  • file associations like .jnlp or .jar files (this requires some registry modifications)
  • 文件关联,如.jnlp或.jar文件(这需要一些注册表修改)

  • browser java plugin registration (which requires also registry modifications)
  • 浏览器java插件注册(也需要注册表修改)

If the last two points do not interest you on the desktop concerned by this deplyment, a simple zip is enough.

如果最后两点对您所关注的桌面不感兴趣,那么简单的拉链就足够了。

#2


4  

I have not idea if this is "the way" to do it, but confronted with a somewhat similar problem, we simply archive an installed JRE with the rest of our application files and make sure that all our start scripts don't use java ..., but rather ..\..\jre\bin\java ... or similar. The JRE is unpackaged as part of our installation process in a subdirectory of where we install and that's that.

我不知道这是否是“方法”,但面对一个类似的问题,我们只是将已安装的JRE与其余的应用程序文件存档,并确保我们所有的启动脚本都不使用java。 ..,而是.. \ .. \ jre \ bin \ java ...或类似的。作为我们安装过程的一部分,JRE在我们安装的子目录中解压缩,就是这样。

#3


1  

http://www.syswow64.co.uk/2013/05/java-7-update-21-1721-enterprise.html

The issue on many blogs and articles is around creating the 'deployment.config' and 'deployment.properties' files for an enterprise deployment. In my case i wanted to set the security level to 'Medium', but everytime I open the Java control panel it was set to the default HIGH setting.

许多博客和文章的问题在于为企业部署创建“deployment.config”和“deployment.properties”文件。在我的情况下,我想将安全级别设置为“中”,但每次打开Java控制面板时,它都设置为默认的HIGH设置。