2021年3月19日星期五

Java: Cannot read package from the unnamed module?

While moving a project to Gradle, I stopped using my custom build of org.json which had a module-info.java fitted to it to comply to the module system. Now, I am using it via Maven normally, and as org.json is not a module by default, it gets put into the unnamed module.

My module-info looks like this:

open module mymodule {      requires java.desktop;      requires java.logging;  }  

I am getting the error:

SomeSourceFile.java: error: package org.json is not visible  import org.json.*;            ^    (package org.json is declared in the unnamed module, but module mymodule does not read it)  

This is logical, except I don't know why my module doesn't read the unnamed module (the purpose of the unnamed module is full backwards compatibility with non-modular software so all packages are exported etc.), and how I could make my module read the unnamed module. As you can see, I have already tried making my module open to no avail.

https://stackoverflow.com/questions/66660963/java-cannot-read-package-from-the-unnamed-module March 17, 2021 at 02:10AM

没有评论:

发表评论