Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - module not found when adding module-info.java

I have a simple hello world project in eclipse that I want to run with java 9. The program runs when I don't have a module-info.java file but when I add that file I get the following error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module modulefinder not found

Steps to reproduce
1. Create a new maven project
2. Change compiler and build path jre to 9
3. Auto generate module-info.java
4. Update junit dependency in junit to 4.12 if eclipse complains
5. Run the project

Is this an eclipse related issue or am I missing something when running the project?

FYI eclipse version I use is Oxygen.1a Release (4.7.1a)

like image 814
Gert Kommer Avatar asked Nov 27 '17 12:11

Gert Kommer


People also ask

How do I import a module into Eclipse?

From the main menu, select File | New | Module from Existing Sources. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open. Select Import module from external model | Eclipse and click Next.

How do I add a module to a java project?

Add a new module to your projectSelect the top-level directory in the Project tool window and press Alt+Insert or select New | Module from the context menu.

What is module-info java in Eclipse?

Yes, module-info. java was introduced in Java 9, with the Project Jigsaw module system. A module is a build artifact (usually a Jar file) that contains a module descriptor that declares the name of the module, what other modules it depends on, what packages it exposes to other modules, and what services it implements.

Where is module-info java located?

The module descriptor ( module-info. java ) needs to be located in the src/main/java directory.


1 Answers

Found the answer based on intellij output:) I had to add the location of the classes to the vm arguments in the run configurations as well as the module name/path to main. like below. See the java -help command for more info regarding -m and -p

enter image description here

like image 162
Gert Kommer Avatar answered Sep 18 '22 22:09

Gert Kommer