16

I migrating a maven project in Java 8 to a Java 9 project without any build tool in Eclipse OxyGen 1a.

So my module-info.java looks like this:

enter image description here

But java.xml.bind is not accessible, although its in my module path:

enter image description here

So what is wrong here?

7
  • 2
    see stackoverflow.com/questions/43574426/… Commented Oct 20, 2017 at 15:28
  • 3
    That module is deprecated. You will need to JAXB as an external library. Commented Oct 20, 2017 at 15:30
  • 1
    It exists in JDK 9, but it’s not in the default module path. Commented Oct 20, 2017 at 15:49
  • 4
    requires java.xml.bind should work. As noted by others, the module is deprecated-for-removal in Java SE but this module leads a double life and so will live on if jettisoned from the JDK. The standalone version, as of version 2.3.0, is an explicit module that you can deploy on the module path (or upgrade module path to override the version in the JDK). To your question, if it works outside of Eclipse then it hints of something in the Eclipse environment. Commented Oct 20, 2017 at 16:36
  • 2
    Related answer for the migration of these API's. Commented Oct 21, 2017 at 7:08

1 Answer 1

16

When compiling an unnamed module, java.xml.bind is not accessible by default, but in a modular project (as in this question) failing to resolve reference to module java.xml.bind was a bug (see edit below).

To work around this until the bug is fixed, you can explicitly include module java.xml.bind by double click on Is modular (see screenshot in the question), and in the dialog that shows, move the desired module from Available modules to Explicitly included modules:

Module properties dialog

Edit: Bug 526054 has been resolved in Eclipse Oxygen.2, and thus a modular project should no longer need the steps above (which are still relevant for code in an unnamed module, though).

Edit 2: In Eclipse 2019-06 the UI for tasks like above has been revamped. Up-to-date documentation can be found in the online help.

Sign up to request clarification or add additional context in comments.

2 Comments

I see a downvote and the answer has not been accepted, which let's me ask: what do you see missing?
Sorry for the late response. Other projects required my attention. So to this issue: it turned out to be a mix of some eclipse problems in combination with jdk9 or newer (just like you already mentioned). Especially when using multi version jars containing builds for different jdks. This SHOULD be fixed in eclipse by now. Will give it a new try in the comming days. No idea why i can't mark your answer as the correct answer though...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.