Search code examples
javaeclipsejava-9java-module

Module xxx not found, required by xxx


I'm trying to build a small program in Eclipse 2020-06 using Java14. I have Guava 29 as a dependency. Here is my module-info.java

module xxx {

   exports main;

   requires java.base;
   requires java.desktop;
   requires java.prefs;
   requires com.google.common;
}

However, when I launch the program, I get this message:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module com.google.common not found, required by xxx

The guava jar is placed under Modulepath. I'm not using any build tools like Maven etc.


After removing the requires, I checked what the compiler would suggest. Here is what the compiler suggests as a requires, but I already had it before. See: https://prnt.sc/unp2hf


Solution

  • I've found a solution to the problem. First, move the dependencies to a folder called modules in your projects root folder. and then add them to the modulepath.

    enter image description here

    Then, in the same window, click Source and edit the Default Output Folder to

    PROJECT_NAME/modules/MODULE_NAME

    enter image description here

    and happily launch the program.