X

Topics and trends related to the Java ecosystem with occasional random rants.

  • Sun |
    July 31, 2013

An Introduction to Java 8 Compact Profiles

James Connors
Principal Solutions Consultant

Java SE is a very impressive platform indeed, but with all that functionality comes a large and ever increasing footprint.  It stands to reason then that one of the more frequent requests from the community has been the desire to deploy only those components required for a particular application instead of the entire Java SE runtime environment.  Referred to as subsetting, the benefits of such a concept would seem to be many:

  • A smaller Java environment would require less compute resources, thus opening up a new domain of devices previously thought to be too humble for Java.
  • A smaller runtime environment could be better optimized for performance and start up time.
  • Elimination of unused code is always a good idea from a security perspective.
  • If the environment could be pared down significantly, there may be tremendous benefit to bundling runtimes with each individual Java application.
  • These bundled applications could be downloaded more quickly.

Despite these perceived advantages, the platform stewards (Sun, then Oracle) have been steadfast in their resistance to subsetting.  The rationale for such a stance is quite simple: there was sincere concern that the Java SE platform would fragment.  Agree or disagree, the Java SE standard has remained remarkably in tact over time.  If you need any further evidence of this assertion, compare the state of Java SE to that of Java ME, particularly in the mobile telephony arena.  Better still, look how quickly Android has spawned countless variants in its brief lifespan.

Nonetheless, a formal effort has been underway having the stated goal of providing a much more modular Java platform.  Called Project Jigsaw, when complete, Java SE will be composed of a set of finer-grained modules and will include tools to enable developers to identify and isolate only those modules needed for their application.  However, implementing this massive internal change and yet maintaining compatibility has proven to be a considerable challenge.  Consequently full implementation of the modular Java platform has been delayed until Java 9.

Understanding that Java 9 is quite a ways off, an interim solution will be available for Java 8, called Compact Profiles.  Rather than specifying a complete module system, Java 8 will define subset profiles of the Java SE platform specification that developers can use to deploy.  At the current time three compact profiles have been defined, and have been assigned the creative names compact1, compact2, and compact3. The table that follows lists the packages that comprise each of the profiles.  Each successive profile is a superset of its predecessor.  That is to say, the compact2 profile contains all of the packages in compact1 plus those listed under the compact2 column below.  Likewise, compact3 contains all of compact2 packages plus the ones listed in the compact3 column.

compact1                     compact2                    compact3
-------------------------- ----------------------- --------------------------
java.io java.rmi java.lang.instrument
java.lang java.rmi.activation java.lang.management
java.lang.annotation java.rmi.registry java.security.acl
java.lang.invoke java.rmi.server java.util.prefs
java.lang.ref java.sql javax.annotation.processing
java.lang.reflect javax.rmi.ssl javax.lang.model
java.math javax.sql javax.lang.model.element
java.net javax.transaction javax.lang.model.type
java.nio javax.transaction.xa javax.lang.model.util
java.nio.channels javax.xml javax.management
java.nio.channels.spi javax.xml.datatype javax.management.loading
java.nio.charset javax.xml.namespace javax.management.modelbean
java.nio.charset.spi javax.xml.parsers javax.management.monitor
java.nio.file javax.xml.stream javax.management.openmbean
java.nio.file.attribute javax.xml.stream.events javax.management.relation
java.nio.file.spi javax.xml.stream.util javax.management.remote
java.security javax.xml.transform javax.management.remote.rmi
java.security.cert javax.xml.transform.dom javax.management.timer
java.security.interfaces javax.xml.transform.sax javax.naming
java.security.spec javax.xml.transform.stax javax.naming.directory
java.text javax.xml.transform.stream javax.naming.event
java.text.spi javax.xml.validation javax.naming.ldap
java.util javax.xml.xpath javax.naming.spi
java.util.concurrent org.w3c.dom javax.script
java.util.concurrent.atomic org.w3c.dom.bootstrap javax.security.auth.kerberos
java.util.concurrent.locks org.w3c.dom.events javax.security.sasl
java.util.jar org.w3c.dom.ls javax.sql.rowset
java.util.logging org.xml.sax javax.sql.rowset.serial
java.util.regex org.xml.sax.ext javax.sql.rowset.spi
java.util.spi org.xml.sax.helpers javax.tools
java.util.zip javax.xml.crypto
javax.crypto javax.xml.crypto.dom
javax.crypto.interfaces javax.xml.crypto.dsig
javax.crypto.spec javax.xml.crypto.dsig.dom
javax.net javax.xml.crypto.dsig.keyinfo
javax.net.ssl javax.xml.crypto.dsig.spec
javax.security.auth org.ieft.jgss
javax.security.auth.callback
javax.security.auth.login
javax.security.auth.spi
javax.security.auth.x500
javax.security.cert

You may ask what savings can be realized by using compact profiles?  As Java 8 is in pre-release stage, numbers will change over time, but let's take a look at a snapshot early access build of Java SE-Embedded 8 for ARMv5/Linux.  A reasonably configured compact1 profile comes in at less than 14MB.  Compact2 is about 18MB and compact3 is in the neighborhood of 21MB.  For reference, the latest Java 7u21 SE Embedded ARMv5/Linux environment requires 45MB.

So at less than one-third the original size of the already space-optimized Java SE-Embedded release, you have a very capable runtime environment.  If you need the additional functionality provided by the compact2 and compact3 profiles or even the full VM, you have the option of deploying your application with them instead.

In the next installment, we'll look at Compact Profiles in a bit more detail.


Join the discussion

Comments ( 16 )
  • Faz Wednesday, July 31, 2013

    Don't any tools exist to produce a stripped down JVM containing a minimal footprint needed to run a particular application ? Given how much information is kept in jar files, and given how long the jvm has been around - this doesn't sound like asking for a miracle...


  • guest Wednesday, September 18, 2013

    This seems to be very much on lines of plug-able and composable runtime with pre-build profiles. Can not this be custom? Or it is J2SE 9 goal?

    Next set of App servers will also have to provide such a capability making things to be available in a composable way and then on-demand, something that WAS Liberty is already able to do.


  • guest Wednesday, September 18, 2013

    The custom capability you ask for will be part of Java 9. Compact Profiles are an interim solution which subset the JRE into a small number of options, each with well known functionality. As Java 9 won't be out for quite a bit, compact profiles aren't going away any time soon. In fact we've modified many Java SE tools to compact profile aware, including javac, jar and the java command.

    If you want to see a video demonstrating compact profiles, check out the blog entry that follows this one:

    https://blogs.oracle.com/jtc/entry/compact_profiles_demonstrated


  • Derek Wednesday, September 18, 2013

    The concept of compact profile is a good start.

    I would think one can customize these because many applications/projects would have classes/libraries that overlap at least two of these profiles.


  • John Friday, September 20, 2013

    The compact packages listed don't include any UI packages, (awt, swing, JavaFX). Are there compact profiles which include JavaFX or other UI technologies?


  • guest Friday, September 20, 2013

    The Three compact profiles introduced so far do not include any graphic components. I'd be curious to see if anything is said about the prospects of some kind of JavaFX profile ate Java One 2013.


  • Tony Saturday, December 14, 2013

    I have downloaded JDK8 developer preview. But I did not see jrecreate scripts anywhere. Is Compact Profiles still included anywhere?


  • guest Tuesday, December 17, 2013

    The subsequent blog post entitled Compact Profiles Demonstrated (https://blogs.oracle.com/jtc/entry/compact_profiles_demonstrated) exaplains the current availabilility of the Java 8 SE-Embedded Early Access (with the jrecreate tool):

    "Members of the Oracle Partner Network (OPN) with a gold membership or higher can download the early access Java 8 binaries of Java SE-Embedded shown here. For those not at this level, it may still be possible to get early access software, but it will require a qualification process beforehand."


  • Tony Tuesday, December 17, 2013

    Does that mean Compact Profile will only be available in Java SE Embedded? I am looking for a way to make a more compact version of the standard desktop Java SE.


  • guest Tuesday, December 17, 2013

    Referring to the subsequent blog post entitled Compact Profiles Demonstrated (https://blogs.oracle.com/jtc/entry/compact_profiles_demonstrated), the full toolset and space optimizations are only available for Java SE-Embedded. However, you can use a form of Compact Profiles with the standard OpenJDK release:

    "It's not as intimidating as it sounds, you can pull down the source code for OpenJDK 8, and build it yourself (http://hg.openjdk.java.net/jdk8/jdk8/raw-file/tip/README-builds.html). By default, compact profiles are not built, but this forum post shows you how (http://mail.openjdk.java.net/pipermail/jdk8-dev/2013-February/002062.html). The reference platform for this software is linux/x86. Functionally, the generated compact profiles will contain the pared down modules for each compact profile, but you'll find the footprint for each to be much larger than the ones demonstrated in this video, as none of the Java SE-Embedded space optimizations are performed by default."


  • Jeff Zhang Thursday, January 16, 2014

    Hi, Why java.beans isn't in compact profiles. I think it is useful.


  • Ben Thursday, April 24, 2014

    I keep trying to figure out a how to get jdwp to work with Embedded Java, using either a full jre or compact3 profile. In both cases, it cannot find libjdwp.so.

    According to the document below, it should be supported, except in the minimal VM option of the JRE. I am using the ARMv5 Linux (linux-arm-sflt) version, which I suspect might not include this anymore? It was in the EJRE7 though, so I'm surprised it is missing now. Does anyone know about this?

    http://docs.oracle.com/javase/8/embedded/develop-applications/headless.htm#CHDHCHCG


  • guest Thursday, April 24, 2014

    Did you issue the jrecreate command with the '--debug' option?


  • Ben Thursday, April 24, 2014

    For future readers, jdwp requires --debug option on jrecreate.sh.

    Thanks to Jim Connors for the answer (and the post!).


  • guest Thursday, August 7, 2014

    Hi! Is the compact1 profile backward compatible with CDC-1.1/FP-1.1 java code?


  • Jim Connors Friday, August 15, 2014

    In general, our experience is that customers have had good success moving applications from CDC to Java SE Embedded with Compact Profiles. With compact1, migration from CDC/FP to Java 8 SE was one of the main factors determining which APIs were and were not not included.

    That being said we cannot guarantee all CDC/FP applicaitions will run on Java SE Embedded compact1 implementations. There have been numerous bug fixes and improvements (most notably security fixes) to the APIs as compared to the very dated CDC/FP APIs that might impact application compatibility.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services