The article presents a perspective on different aspects of compact profiles in Java 8 including relevance of this feature in the first place and, when would you want to use it. As I am also getting up to speed with compact profiles, I do understand that there could be further detail to it that I might have missed and thus, would appreciate if you could share your perspectives as well.
What is Compact Profile?
As defined on Oracle compact profile overview page, compact profile enable reduced memory footprint for applications that do not require the entire Java platform. In Java 8 release, compact profiles provide three different groupings of libraries that you could see on this page. Compact profiles are present in additive layers. This means that each Profile contains all of the APIs in the previous smaller Compact Profiles and adds appropriate APIs on top when used. Video on this page demonstrates on how to create profiles. Java 8 saw release of following three profiles:
Why Compact Profiles?
The primary motivation behind “Compact Profiles” feature is to allow applications run on resource-constrained devices without having the need to require the entire Java SE Platform. In simpler words, the applications that do not need Swing/AWT/2D graphics libraries would only use a profile which does not contain those libraries. That would, thus, reduce the overall size of the platform libraries achieving a considerable space savings.
Following are some of the use-case/problem scenarios that motivated the release of compact profiles feature:
- Reduced Application Memory Footprint: Many a times we have come across scenarios where our code base only took 20 MB and the overall deployment went more than 200 MB or so whose primary contributor had been the Java SE runtime (approx. 140 MB for Java 7 runtime). With compact profiles, one could deploy application with only required runtime libraries thereby saving lot of memory space. Following diagram depicts a viewpoint on compact profiles demonstrating on how it leads to reduced memory footprint:
- Need for Smaller Java Environment in Resource-constrained Smaller Devices: One of the main problem addressed by compact profile feature is the need for smaller Java environment that could be run on multiple smaller devices such as mobile, wearable such as glass, watch and bulb (in recent future) etc. With smaller java environment, following could as well be achieved with compact profile:
- Less storage resources
- Less compute resources
- Faster startup time (always been the complaint of many)
- Higher performance
- Quicker download
- Precursor to Java modular system: Java modular system (Project Jigsaw) in later releases of Java (Java 9 or so) would eventually have consisted compact profiles. However, it looks like a thought out strategy to lay down the foundation of futuristic Java modular system by releasing compact profile in Java 8. This would ease the process of backward compatibility that Project Jigsaw would need at the time of release.Project Jigsaw is primarily aimed to create Java platform as modular system which would consists of different libraries in form of modules. Once you have created the application, you would be able to use a tool which would decide what modules (libraries) are required by the application and thus, would bind the application with only required set of modules. Compact profile shall enable independent JREs to be created with pre-defined modules (representing one or more libraries)
When to use Compact Profiles?
Following are use-cases when compact profiles could be used:
- Selective Java runtime for applications thereby reducing overall memory footprint. This becomes much more important if you are planning to make your application downloadable. Often, larger download size is one of the reasons your application do not get downloaded. Irrespective of download size, would not we want our application footprint to be as less as possible? That would only mean that sooner than later, compact profile would become a way of life with Java developers and, enterprise would start considering usage of this feature and how to migrate their existing setup.
- Selective Java runtime on smaller devices. As you start thinking of future, when wearables & internet of things and related technologies take center stage as result of smart appliances coming into picture, compact profiles would have tremendous role to play owing to its characteristics of reducing memory footprint.
Follow him on Twitter and Google+.
Latest posts by Ajitesh Kumar (see all)
- Learn R – How to Define Function in R - June 3, 2015
- Learn R – How to Create Multiple Density Plots using GGPlot - June 2, 2015
- Learn R – How to Create Density Plot over Histogram - June 2, 2015