Error occurred during initialization of boot layer FindException: Module not found
Andrew Mclaughlin
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 found
The command line that I executed was:
java --module-path bin -m 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 the com.pantech.myModule directory that is located in the bin directory. The HelloWorld.class file contains the main method and is located in the package directory within the com.pantech.myModule directory. Therefore, the pathname of the HelloWorld.class file is bin\com.pantech.myModule\com\pantech\myModule\HelloWorld.class.
The HelloWorld class is in the com.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?
611 Answers
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.
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!
1I 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(""); System.out.println("Google is selected"); } catch (Exception e) { System.err.println(e); } }
} 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> 2 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.
I solved this issue by going into Properties -> Java Build Path and reordering my source folder so it was above the JRE System Library.
1I just encountered the same issue after adding the bin folder to .gitignore, not sure if that caused the issue.
I solved it by going to Project/Properties/Build Path and I removed the scr folder and added it again.
check your project build in jdk 9 or not above that eclipse is having some issues with the modules. Change it to jdk 9 then it will run fine
This problem occurred for me after deleting my bin folder in order to get it out of my git history. To fix it In Eclipse:
- Delete the project (from Eclipse, not from disk)
- Reimport it.
Try removing the JRE System Library from the Java build path of the project. Then add that again under the Modules by clicking Add Library.
I faced same problem when I updated the Java version to 12.x. I was executing my project through Eclipse IDE. I am not sure whether this error is caused by compatibility issues.
However, I removed 12.x from my system and installed 8.x and my project started working fine.