Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

Java 9: Module java.xml.bind is not accessible in Eclipse

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...