Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Java fail to run class- error occurred during initialization of boot layer- Module mods not found

Tags:

java

java-9

I have gone through the java 9 jigsaw tutorial. I have been struggling to run class, java throws below error-

java --module-path mods -m mods/com.test/com.test.HelloWorld
Error occurred during initialization of boot layer
java.lang.module.FindException: Module mods not found

Javac command-

javac -d mods --module-source-path src $(find src -name '*.java')

I am using mac, java version-

$ java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Am I missing anything?

like image 247
rashmi mardur Avatar asked Oct 14 '17 18:10

rashmi mardur


2 Answers

Remove additional mods from module name-

java --module-path mods -m com.test/com.test.HelloWorld
like image 143
Rahul Sharma Avatar answered Nov 08 '22 06:11

Rahul Sharma


The -m flag accepts the module name and the main class you want to run. The module name is com.test, hence the command to run the class should be:

java --module-path mods -m com.test/com.test.HelloWorld

The --module-path mods tells java where to search for to find com.test.

like image 32
M A Avatar answered Nov 08 '22 06:11

M A