What is the meaning of profile (compact1, compact2, compact 3) in Java API documentation?

Compact profiles are subsets of the full Java platform APIs, to allow running with a smaller JRE. Many programs (especially in embedded environments) don’t need libraries like Swing or CORBA — they’re just wasted space. From the Oracle Java SE Embedded 8 Compact Profiles Overview:

A compact profile is a subset of the full Java SE Platform API. Because they have a smaller storage footprint, compact profiles can enable many Java applications to run on resource-constrained devices. Choosing a compact profile that closely matches an application’s functional needs minimizes the storage devoted to unused functions. There are new embedded developer tools in Java SE Embedded 8 including jrecreate and jdeps, which allow a developer to customize the Compact Profile runtime environment for a platform, and to find the Compact Profile dependencies for analysis during platform development.

Compact profiles address API choices only; they are unrelated to the Java virtual machine, the language proper, or tools. So, care must be taken to match the Java virtual machine supported functionality with the API support needed.

That page also lists the contents of each profile. The currently defined profiles all have a subset relationship (compact2 includes compact1, compact 3 includes compact2).

Use the -profile option to javac to compile against a profile. javac will complain if the source uses an API not available in the profile, like in this example from the javac doc:

./javac -profile compact1 Paint.java
Paint.java:5: error: Applet is not available in profile 'compact1'
import java.applet.Applet;

Leave a Comment