I have created a multimodule project with the following structure
myproject
|- mymodule
|- src
|- main
|- java
|- com
|- mymodule
|- Util.java
|-newmodule
|-src
|-main
|-java
|-com
|-newmodule
|- Main.java
|-module-info.java
Now i want to use Util.java which is a non modularized code in a modularized module newmodule. i have declared following in newmodule
module newmodule {
requires mymodule;
}
Project is compiling fine, but Intellij is showing module not found and package com.mymodule is declared in unnamed module , module 'newmodule' does not read it.
How to resolve this issue?
And one more question does all the old non modular code is by default turn into automatic-module in java 9 if i don't even modularized legacy modules?
mymodule
as an explicit module withmodule-info.java
in it as well(exports the package as well). – Oilerjavac
error might incorrectly use the package name as module name as well, e.g. "package mypackage is declared in the unnamed module, but module mypackage does not read it", see JDK-8233524. – Forwards