Run modes in AEM allow you to configure AEM instances for specific purposes.
For example, We can configure environment specific OSGI Services meta data manually from felix console, But the problem here is whenever new build is deployed the OSGI meta data reset to default values , so again we have to configure. Instead of doing manually in felix console, we can create run mode config nodes in repository, sling will take these configuration automatically when we start the instance or config node update  based on run mode values.

Topics :

Run Mode types in AEM:

There are two types of run modes.

  1. Standard run modes – author,publish,samplecontent,nosamplecontent
  2. Custom run modes –  dev,qa,stage,prod ..etc.

Standard run modes set up:

We can configure standard run modes directly by renaming jar file ,Standard run modes are used at installation time and then fixed for the entire lifetime of the instance, they cannot be changed.

The naming convention to for AEM 5.6.1 and later is:


1. author – Run mode for author instance.
2. publish – Run mode for publish instance.
3. samplecontent – Run mode will install sample content.
4. nosamplecontent – Run mode will not install sample content.

Custom run modes set up:

We can define custom run modes different ways ,below are ways .

Using the file :

The file can be used to define the required run mode:

  1. Edit the configuration file:
  2. Add the following properties; the following example is for author:

Using the  -R option :

A custom run mode can be activated by using the -r option when launching the quickstart. For example, use the following command to launch a AEM instance with run mode set to dev.

java -jar cq-56-p4545.jar -r dev

Using a system property in the start script:

  • A system property in the start script can be used to specify the run mode.
    For example use the following to launch an instance as a production publish instance located in the US:,prod,us

Order of precedence of run modes:

Here my question is what happens if we did all above custom run mode configuration at a time,which one will take precedence .

below are the order of precedence of run modes.

  1. Start jar (by double clicking) – In this you do not have option to set run mode in, start script first time. JAR name takes precedence.
  2. Unpack jar and specify run mode as system properties in start script – JAR name doesn’t comes to picture here. In this you do not have option to set run mode in System properties takes precedence.
  3. Even if we change run mode in JAR name, it doesn’t changes the installation time run mode. For custom run mode, JAR file name is not applicable. Order of precedence is -> specifying -r option (command line jar option) -> system properties (start script).

Read Sling run modes in Java:

We can read sling run modes directly from SlingSettingsService OSGI service.

private SlingSettingsService slingSettingsService;