Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripping the JRE to be bundled with an application - what can I omit?

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.

like image 537
Joonas Pulakka Avatar asked Nov 26 '10 07:11

Joonas Pulakka


People also ask

What is bundled JVM?

The bundled JVM is the recommended JVM and is located within the jdk directory of the Elasticsearch home directory. “To use your own version of Java, set the JAVA_HOME environment variable. If you must use a version of Java that is different from the bundled JVM, we recommend using a supported LTS version of Java.

How to check the JRE version on mac?

Determining the JRE Version Installed on macOS The JRE version installed on the system can be determined in one of two ways: From System Preferences, and then the Other section, click the Java icon. This starts the Java Control Panel. You then click About to display the version information.


1 Answers

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.

like image 174
Thilo Avatar answered Oct 13 '22 01:10

Thilo