"package exists in another module" error when setting up JDK11 source code in Intellij IDEA

665 views Asked by At

I downloaded OpenJDK11 source code and tried to set it up in Intellij IDEA(version 2022.1.3) with JDK correto-11.

When I build the project, an error says: "java: package exists in another module: java.base" as shown below.

Does anyone have any idea how to fix it? Thanks a lot.

enter image description here

1

There are 1 answers

0
Michael Fekadu On

I often fix this by deleting the conflicting module. Usually it's brought in as a transitive dependency.

In my case, my main package uses JDK11, but the transitive dependency uses JDK8 and bundled some Java8 source code into itself. Furthermore, it was unused because that library only contained some model code.

In my case, it's usually something like generated-src/java.base or generated-src/java.time

TL;DR = try deleting that src/java.base and see if IntelliJ will happily build.