2

When using JDK 11, Eclipse 2019-03 and jaxb-api (version 2.4, latest available in maven repository), Java Editor in Eclipse highlights the line:

import javax.xml.XMLConstants;

as an error:

The package javax.xml is accessible from more than one module: unnamed, java.xml

But the code compiles and no errors are displayed in Problems tab. Removing jaxb-api dependency makes the error go away. jaxb-api in this project is on the classpath and contains the following packages:

javax.xml.bind;
javax.xml.bind.annotation;
javax.xml.bind.annotation.adapters;
javax.xml.bind.attachment;
javax.xml.bind.helpers;
javax.xml.bind.util;

Is it a bug in Eclipse or a problem in the dependency/project?

Enzomatric
  • 487
  • 8
  • 18

2 Answers2

4

Yes, this is a bug of the Eclipse 2019-03 Java IDE (in jaxb-api javax.xml is a subpackage, which is allowed, but not a real package, which would not be allowed):

Eclipse Bug 546315 - [11] "The package […] is accessible from more than one module: , […]" error shown in Java editor by mistake

The bug has already been fixed. So either ignore it (since the code is compiled) or use a newer version like Eclipse 2019-06 (4.12).

nitind
  • 18,165
  • 4
  • 33
  • 41
howlger
  • 27,010
  • 8
  • 46
  • 83
1

This happens when you have added the external jars in the ModulePath.

Solution:

1) Remove the external jars from the node "Modulepath". 2) Select the node "Classpath" then add the external jars. 3) Review that all the jars are under the node "Classpath".