Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

  1. Make sure to update to the latest version of aem-global-parent (at least version 1.2.34, which includes global-parent 26).
  2. Update properties in your parent pom to define the Java version to build against:
    • Remove:

      Code Block
      xml
      xml
          <!-- compiler settings -->
          <build.compiler.source>1.8</build.compiler.source>
          <build.compiler.target>1.8</build.compiler.target>


    • Add instead:

      Code Block
      xml
      xml
          <!-- Java version -->
          <java.version>11</java.version>


  3. 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):

    Code Block
    xml
    xml
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-annotation_1.3_spec</artifactId>
      <scope>provided<scope>
    </dependency>


  4. 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 product artifacts compatible with Java 8, do the same steps as described above, but add a different properties block:

Code Block
xml
xml
    <!-- Java version -->
    <java.version>1.8</java.version>
    <build.compiler.release>8</build.compiler.release>


Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@4e99be7
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "kb-how-to-article" , "Maven" ) and type = "page" and space = "WCMIO"
labelskb-how-to-article

...