Home > Java > javaTutorial > Why Can\'t Eclipse Load XML Classes After JDK 10 Migration?

Why Can\'t Eclipse Load XML Classes After JDK 10 Migration?

DDD
Release: 2024-11-30 12:42:12
Original
379 people have browsed it

Why Can't Eclipse Load XML Classes After JDK 10 Migration?

Eclipse Fails to Load XML Classes After Switching to JDK 10

When migrating a Maven project to JDK 10, Eclipse developers may encounter an issue where XML-related classes become inaccessible during compilation. This error only occurs within the Eclipse build environment, while Maven builds and individual class browsing remain unaffected.

Cause:

The source of this problem lies in the unnamed module utilized by the project, which lacks a module-info.java. This implies that code is compiled within the unnamed module, which reads observable named and unnamed modules, including java.xml. However, the classpath also contains xml-apis.java, contributing conflicting packages of the same names.

Resolution:

To resolve this issue, two options are available:

1. Create a module-info.java file:

Add a module-info.java file to your project and specify which modules are required:

requires ...*;
Copy after login

Replace ... with either java.xml or xml.apis.

2. Limit Observable Modules in Eclipse:

In Eclipse, navigate to Java Build Path > Libraries > Classpath and open the "Modularity Details" dialog. Exclude java.xml from the set of observable modules by moving it from the "Explicitly Included Modules" to the "Available Modules" section. Any modules essential to your project can be selectively added back.

Additional Information:

  • Eclipse now provides a more accurate error message: "The package javax.xml.xpath is accessible from more than one module."
  • The behavior of the compiler when switching the order of JRE and JAR files on the classpath remains enigmatic.

The above is the detailed content of Why Can\'t Eclipse Load XML Classes After JDK 10 Migration?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template