9

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
  • 1
    You may be interested in http://stackoverflow.com/questions/2258932/embed-a-jre-in-a-windows-executable – Thilo Nov 26 '10 at 08:07

2 Answers2

2

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.

Thilo
  • 257,207
  • 101
  • 511
  • 656
1

While this doesn't strictly relate to the question, for whole-program (or whole-platform) optimization of removing "un-needed code", I have found ProGuard to be a good tool. YMMV.