Java – Unable to read unnamed module

Unable to read unnamed module… here is a solution to the problem.

Unable to read unnamed module

I

had a very nasty question that I didn’t understand….

  1. We have a whole library of utilities written in jdk8, which has nothing to do with puzzles, so we also do not set the automatic module name in the META-INF file.

  2. Now we need to migrate the product to Java 11 using these utility libraries.

  3. I created a module-info.java and entered all the required modules, but there are some issues with util-libraries.
  4. Some utility libraries are loaded as unnamed modules, which can be added as required modules. But for some of the others in these utility libraries, it is not possible to add them because they do not get module names based on their jar files.

From my IDE I get the following error:

Package “x” is declared in an unnamed module, but module “y” does not read it.

Package X is in one of our utility libraries, and module Y is the product that should be migrated to Java 11.

Any ideas for me to understand the issue?

Best regards

Solution

The solution to this particular problem is my IDE. IntelliJ does not support reading Unnamed Modules or Automatic Modules from Projects imported into the IDE. I’ve started bug reporting at jetbrains.

Related Problems and Solutions