Error occurred during initialization of boot layer FindException: Module not found
Solution 1
The reason behind this is that meanwhile creating your own class, you had also accepted to create a default class as prescribed by your IDE and after writing your code in your own class, you are getting such an error. In order to eliminate this, go to the PROJECT folder → src
→ Default package. Keep only one class (in which you had written code) and delete others.
After that, run your program and it will definitely run without any error.
Solution 2
I had the same issue while executing my selenium tests and I removed the selenium dependencies from the ModulePath to ClassPath under Build path in eclipse and it worked!
Solution 3
I had similar issue, the problem I faced was I added the selenium-server-standalone-3.141.59.jar
under modulepath
instead it should be under classpath
so select classpath
via (project -> Properties -> Java Bbuild Path -> Libraries)
add the downloaded latest jar
After adding it must be something like this
And appropriate driver for browser has to be downloaded for me i checked and downloaded the same version of chrom for chrome driver and added in the C:\Program Files\Java
And following is the code that worked fine for me
public class TestuiAautomation {
public static void main(String[] args) {
System.out.println("Jai Ganesha");
try {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("no-sandbox");
chromeOptions.addArguments("--test-type");
chromeOptions.addArguments("disable-extensions");
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.com");
System.out.println("Google is selected");
} catch (Exception e) {
System.err.println(e);
}
}
}
Solution 4
You say that your module-info.java
contains
module myModule {}
That means it declares a module called myModule
, not com.pantech.myModule
. Pointing this from the command format:
-m <module-name>/<main-class>
Solution 5
I had the same issue and I fixed it this way:
- Deleted all projects from eclipse, not from the computer.
- Created a new project and as soon as you write the name of your project, you get another window, in which is written: "Create module-info.java". I just clicked "don't create".
- Created a package. Let us call the package
mywork
. - Created a Java class inside the package
myWork
. Let us call the classHelloWorld
. - I run the file normally and it was working fine.
Note: First, make sure that Java is running properly using the CMD command in that way you will understand the problem is on eclipse and not on JDK.
Related videos on Youtube
D. Pante
Updated on July 09, 2022Comments
-
D. Pante almost 2 years
Executing a simple "Hello World" program using Java 9 results in the following error message:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module com.pantech.myModule not foundThe command line that I executed was:
java --module-path bin -m com.pantech.myModule/com.pantech.myModule.HelloWorld
This command line is executed from the parent directory of my
bin
directory that contains all of the.class
bytecode files.The
module-info.class
file is located in thecom.pantech.myModule
directory that is located in thebin
directory. TheHelloWorld.class
file contains the main method and is located in the package directory within thecom.pantech.myModule
directory. Therefore, the pathname of theHelloWorld.class
file is bin\com.pantech.myModule\com\pantech\myModule\HelloWorld.class.The
HelloWorld
class is in thecom.pantech.myModule
package (package name same as the module name).I am using Windows 10 as the Operating System. From everything that I have read, the above command line should be correct. Any suggestions on how to fix this?
-
ernest_k about 6 yearsIn which directory is the compiled module file? Seems like the directory you need to add to module path is
bin\com.pantech.myModule
-
D. Pante about 6 yearsThe compiled module file (module-info.class) is located in the bin\com.pantech.myModule directory.
-
Naman about 6 yearsCould you share the class definition(starting from package declaration) and module definition as well, for the above to be reproduced, please? And honestly, for such experiments, I take the quick-start here for reference. (you might want to cross verify the compilation commands as well)
-
D. Pante about 6 yearsModule definition file (module-info.java) located incom.pantech.myModule directory contains the following: module myModule {} The source code for the HelloWorld file contains the following: package com.pantech.myModule; public class HelloWorld { public static void main(String [] args) { System.out.println("Hello World from module"); } }
-
Naman about 6 years@D.Pante The answer by tretegfdg seems to be pointing out the mistake you made. That's why I suggest referring to the guide as well. The module name there is same as the package name
com.greetings
(in the sample), hence their command works. Also, refer to docs.oracle.com/javase/9/tools/java.htm for more details on the commands used. -
SedJ601 almost 5 yearsIn Netbeans, I just used
Clean and Rebuild Project
and it worked.
-
-
D. Pante about 6 yearsThanks. The problem was solved by changing the module name in the module-info.java file to com.pantech.myModule instead of just myModule. The solution should have been obvious to me, but I guess that I was looking for something more obscure.
-
Bhaumik Bhatt over 3 yearsTries Same thing but it does not resolve the error
-
Bhaumik Bhatt over 3 yearsCan you please explain? I am still not able to figure out what changes i am supposed to make.
-
bunkinet over 2 yearsI faced the same issues and this fixed it