Close

Java 11 - Removal of Java EE modules (JEP 320)

[Updated: Sep 27, 2018, Created: Sep 27, 2018]

In Java 9, the modules which contain Java EE technologies were deprecated for removal in a future release.
The flag --add-modules can be used in JDK 9 to resolve these modules.

Java 11, removes all JEE related modules (JEP 320). Now --add-modules no longer works.
In Java 11, these JEE technologies can be deployed in class path (or module path for modular applications).

The following example shows how to use JAXB API using maven dependencies.

Example

pom.xml

<project .....>
<modelVersion>4.0.0</modelVersion>

<groupId>com.logicbig.example</groupId>
<artifactId>java-11-jee-module-removal</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
@XmlRootElement
public class MsgObj {
  private String msg;
    .............
}
public class MsgUnMarshaller {
  public static void main(String... st) throws JAXBException {
      JAXBContext jaxbContext = JAXBContext.newInstance(MsgObj.class);
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

      StringReader reader = new StringReader("<msgObj><msg>test msg</msg></msgObj>");
      MsgObj msgObj = (MsgObj) unmarshaller.unmarshal(reader);
      System.out.println(msgObj);
  }
}
MsgObj{msg='test msg'}

Example Project

Dependencies and Technologies Used:

  • jaxb-runtime 2.3.0.1: JAXB (JSR 222) Reference Implementation.
  • activation 1.1.1: The JavaBeans(TM) Activation Framework is used by the JavaMail(TM) API to manage MIME data.
  • JDK 11
  • Maven 3.5.4

Java 11 - Using JAXB after JEE removal Select All Download
  • java11-jee-module-removal
    • src
      • main
        • java
          • com
            • logicbig
              • example
    • pom.xml

    See Also