2

How can i bundle a stripped down JVM to run just my application?

i would like to strip down the JVM so that i can include it in my application. I know that exe wrappers can do this but what i would like to know is how? so that i can script it and create bundles for multiple OS's not just Windows.

Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241

3 Answers3

2

Even though it might be possible to strip down the JRE distribution from a technical perspective, please have a close look at the license agreement. For Java 6 it states:

[...] Sun grants you a non-exclusive, non-transferable, limited license without fees to reproduce and distribute the Software, provided that (i) you distribute the Software complete and unmodified and only bundled as part of, and for the sole purpose of running, your Programs [...] {Supplemental License Terms, (B)}

I'd read it like that: you're only allowed to distribute a complete (Sun) JRE 6 (or JDK 6).

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • 3
    This is not 100% accurate. First, the license permits omitting some files when redistributing in the JRE, though not the largest ones. Second, there are open-source implementations: OpenJDK, Apache Harmony, GCJ. Finally, there is a commercial Java implementation that enables you to omit parts of the Java library when packaging your app, in a license-compliant way (see my answer below). – Dmitry Leskov Dec 22 '10 at 07:16
1

You may considerably reduce the download size of java applications while maintaining compliance with the license.

Dmitry Leskov
  • 3,233
  • 1
  • 20
  • 17
-1

For the vast majority of users (that is to say those who have a Java runtime installed) you shouldn't need to distribute your own custom execution environment, and in fact doing so goes against the "spirit" of Java.

Java code is designed to be runnable in any environment, and you can easily replicate the double-click-and-run behavior of an .exe with a Java program by creating an executable .jar.

This may not be quite the answer you're looking for, and if so the answers discussing licensing stripped-down JVMs are what you need. But most Java developers should have no need to jump through such hoops. Simply distribute your Jars and let users install a Java runtime themselves.

Community
  • 1
  • 1
dimo414
  • 47,227
  • 18
  • 148
  • 244
  • As mentioned in this article: http://blog.vinceliu.com/2008/01/bundling-minimal-bare-bones-jvm-with.html "One of the gripes why people dislike Java as a desktop application is probably because of the additional requisite of having the presence of the JVM, which is generally either not bundled with any of the major operating systems in the market today, or that it can be the wrong version of the JVM that is needed. This makes it really annoying for end users if they just wanted something that 'works out of the box'." – Sridhar Sarnobat Oct 19 '15 at 08:03
  • 1
    "Just works out of the box" is the very idea of Java. Code with no runtime requirements needs to be compiled for each individual platform the developer intends to support, and end-users need to know which version they need. The burden is also now on the end user to ensure they keep these programs up to date in the event of bugs and security issues. With Java developers get an easier development process and users get an easier, safer application. I appreciate the appeal of a single .exe, but it's apparent simplicity is a misnomer. – dimo414 Oct 19 '15 at 09:58