/
How to switch your AEM Maven Project to Java 11
How to switch your AEM Maven Project to Java 11
You are using an AEM Project that was built by the wcm.io Maven Archetype for AEM or inherits the build settings from wcm.io AEM Global Parent.
Your project is currently configured for Java 8 and you want to switch to Java 11 (which is supported and recommended since AEM 6.5).
Switch Maven Project to Java 11
- Make sure to update to the latest version of
aem-global-parent
(at least version 1.2.34, which includesglobal-parent
26). - Update properties in your parent pom to define the Java version to build against:
Remove:
<!-- compiler settings --> <build.compiler.source>1.8</build.compiler.source> <build.compiler.target>1.8</build.compiler.target>
Add instead:
<!-- Java version --> <java.version>11</java.version>
If you are using annotations like
javax.annotation.PostConstruct
in your Sling Model classes you need to add this dependency to your OSGi bundle POMs (it's version is defined in the wcm.io AEM Dependencies POM since version 6.5.0):<dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-annotation_1.3_spec</artifactId> <scope>provided<scope> </dependency>
- If you are using Eclipse to develop your project make sure the Eclipse IDE itself is running with Java 11 as well. You may add the path
<Java 11 Path>/bin
to your system path (before any other Java paths) to achieve this.
Compile with Java 11 against Java 8
If you want to compile with Java 11 but produce artifacts compatible with Java 8, do the same steps as described above, but add a different properties block:
<!-- Java version --> <java.version>1.8</java.version> <build.compiler.release>8</build.compiler.release>
Related articles
, multiple selections available,
Related content
Migrate from wcm.io Maven aem-global-parent 1.1.x to 1.2.x
Migrate from wcm.io Maven aem-global-parent 1.1.x to 1.2.x
More like this
Migrate from wcm.io Maven aem-global-parent 1.4.x to 1.5.x
Migrate from wcm.io Maven aem-global-parent 1.4.x to 1.5.x
More like this
What's new in Maven Archetype for AEM 2.4.0
What's new in Maven Archetype for AEM 2.4.0
More like this
How to make your AEM application compatible with AEM 6.2
How to make your AEM application compatible with AEM 6.2
More like this
How to switch from maven-bundle-plugin to bnd-maven-plugin
How to switch from maven-bundle-plugin to bnd-maven-plugin
More like this
Migrate AEM Mocks Unit Tests from JUnit 4 to JUnit 5
Migrate AEM Mocks Unit Tests from JUnit 4 to JUnit 5
More like this