简体   繁体   中英

Migrating from JDK 8 to OPEN JDK 11 - Missing imports

I am trying to migrate my application from Java 8 to Open JDK 11.

In which few of the imports are missing in JDK 11. For example I could not find below imports

import org.w3c.dom.Document;
import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
import org.xml.sax.SAXException;

But when i tired to add external jar for (w3c-dom.jar), we are getting the below error

The package org.w3c.dom is accessible from more than one module: , java.xml

As like the above, same error is occurring for all the imports

The package org.xml.sax is accessible from more than one module: , java.xml

Please suggest your views on the above error.

I faced similar issue, like mentioned below.

The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml.

Because there was a dependency which internally generating xml-apis.jar , and this jar was actually created the problem. I followed below mentioned steps and it helped me.

  • Go to .m2 repository folder of your system and check if xml-apis.jar is present, if yes it means this jar is creating problem.
  • Delete this jar from repository folder.
  • And exclude the xml-apis transitive dependency in your pom.xml.
  • Refresh, recompile project and check.

Note : It may be a different dependency in your case which generates this xml-api.jar, so find that dependency and exclude xm-api.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM