Migrating Apps to Java 10

If you’re using Maven, set the compiler source/target version to 10 like the following:

<properties>
    <maven.compiler.source>10</maven.compiler.source>
    <maven.compiler.target>10</maven.compiler.target>
</properties>

You don’t need to expliclty add build plugin to configure the maven-compiler-plugin for jdk version.

if you’re coming from JDK 8, you might face this common exception.

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) … 15 more

JAXB is moved into its own modulejava.xml.bind, you need to explicitly specify the dependencies.  You can use the command-line option --add-modules java.xml.bind to fix the issue.  Likewise, you might face ClassNotFound exception for javax/activation/DataSourceclass.

Since Java 9 deprecated the six Java EE API’s (JAXB is one of them), it’s better to add them as dependency (–add-modules probably will not work in Java 10).

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.8</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>

 

Refer: https://stackoverflow.com/questions/48204141/replacements-for-deprecated-jpms-modules-with-java-ee-apis/48204154#48204154

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s