剥离JRE以与应用程序捆绑在一起 - 我可以省略什么? [英] Stripping the JRE to be bundled with an application - what can I omit?

查看:112
本文介绍了剥离JRE以与应用程序捆绑在一起 - 我可以省略什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在将JRE与我的应用程序捆绑在一起,只需将文件从 $ JAVA_HOME / jre 复制到我的应用程序的发行版。这可能违背了Java的精神,但它通过确保我的应用程序在经过测试的JRE版本上运行来减少潜在问题(包括比特;我使用一些JNI,它要求JRE是32位版本)。



它工作正常,但整个发行版有点大,所以可能会遗漏一些不必要的文件?实际上, $ JAVA_HOME / jre / README.txt 包含以下建议:


组成Java SE运行时环境的文件分为
两类:必需和可选。可以通过
供应商自行决定从Java SE运行时环境的重新分发中排除
的可选文件。



以下部分包含文件列表可以选择使用Java SE Runtime
环境从重新分发中省略
和目录。不在这些可选文件列表中的所有文件必须在运行时环境的重新分发中包含



...在Microsoft Windows上重新分发JRE时私有
应用程序运行时(其他应用程序无法访问)
带有自定义启动器,以下文件也是
可选。这些是在Internet Explorer和Mozilla系列浏览器中使用
用于Java支持的库和可执行文件;
在私人JRE重新分发中不需要这些文件。


令我感到困惑的是,可选文件列表包括,其中:

  bin\java.exe 
bin\javaw.exe
bin \ javaws.exe

如何 java / javaw.exe 是可选的吗?如果没有它们我应该如何启动Java应用程序?显然我不知道某些事情(很可能),或说明是完全错误的。

解决方案


当使用自定义启动器将Microsoft Windows上的JRE作为私有应用程序运行时(其他应用程序无法访问)重新分发时,以下文件也是可选的。


如果在自己的应用程序中嵌入JVM(通过链接其共享库),则不需要独立的启动程序可执行文件。我认为Eclipse就是这样工作的。例如。



如果你的应用程序使用java可执行文件(例如通过批处理文件),那么你当然需要它们。 / p>

I've been bundling JRE with my app by simply copying the files from $JAVA_HOME/jre to my app's distribution. This may be against the spirit of Java, but it reduces potential problems by ensuring that my app runs on a version of JRE that it was tested on (including the bitness; I use some JNI which requires that the JRE is a 32-bit version).

It works fine, but the whole distribution is somewhat big, so maybe some unnecessary files could be left out? Indeed, $JAVA_HOME/jre/README.txt contains the following advice:

The files that make up the Java SE Runtime Environment are divided into two categories: required and optional. Optional files may be excluded from redistributions of the Java SE Runtime Environment at the vendor's discretion.

The following section contains a list of the files and directories that may optionally be omitted from redistributions with the Java SE Runtime Environment. All files not in these lists of optional files must be included in redistributions of the runtime environment.

...When redistributing the JRE on Microsoft Windows as a private application runtime (not accessible by other applications) with a custom launcher, the following files are also optional. These are libraries and executables that are used for Java support in Internet Explorer and Mozilla family browsers; these files are not needed in a private JRE redistribution.

What puzzles me is that the list of optional files includes, among others:

bin\java.exe
bin\javaw.exe
bin\javaws.exe

How can java/javaw.exe be optional? How am I supposed to start a Java application without them? Apparently I don't know something (likely), or the instructions are simply wrong.

解决方案

When redistributing the JRE on Microsoft Windows as a private application runtime (not accessible by other applications) with a custom launcher, the following files are also optional.

If you embed the JVM (by linking against its shared libraries) in your own application, you do not need the standalone launcher executables. I think Eclipse works that way, for example.

If your app uses the java executable (via a batch file for example), then you need them, of course.

这篇关于剥离JRE以与应用程序捆绑在一起 - 我可以省略什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆