I have the following error when trying to run Java project:
Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package jdk.internal.jrtfs in both module java.base and module jrt.fs
I tried to remove JDK and JRE and install them again, but the problem is still there.
Could someone explain how to solve this issue?
Could system restore help?
asked Sep 20, 2018 at 13:34
user300045user300045
2291 gold badge3 silver badges8 bronze badges
4
This problem comes in project when many main() available in your Spring boot project try to remove others or run this as separate java application.
answered Oct 17, 2022 at 8:34
I ran into same issue, I think it’s something to do with the newer version of Java.
When creating a new java project heres a picture
click version 1.8 and then save it and it should work.
answered Oct 4, 2018 at 0:30
If your program works on command line, the problem is not the JDK installations but the IDE which is Eclipse. try reinstalling the Eclipse IDE.
answered Jun 12, 2020 at 1:41
I ran into the same issue today and I tried «Run as -> Java Application». Then it was fixed. (btw, the jdk I used was jdk-11.0.2)
Hope you would find this helpful!
answered Sep 26, 2020 at 10:29
This can happen when you have a run configuration with no project and main class configured. You can fix this by going to your run configurations and deleting the empty configuration or choosing the correct one when running it.
answered Nov 23, 2020 at 9:56
I had the same issue. It seems that the dependencies on the Modulepath
got mixed up.
A rebuild of the project after deleting the Launch Configuration
file of the project under
…workspace.metadata.pluginsorg.eclipse.debug.core.launches
and deleting the bin
directory fixed the problem.
answered Jan 24, 2021 at 12:42
KaplanKaplan
1,9029 silver badges10 bronze badges
Clean project then create a new configuration where you indicate the file that contains the main method in your project the run the project again
answered Oct 17, 2021 at 11:19
Using [Eclipse IDE for Enterprise Java and Web Developers],
[Version: 2022-06 (4.24.0)].
This resolved it for me: [delete module-info.java] from Project.
answered Jul 26, 2022 at 20:33
In the run configuration mention the Project and the name of the main class.
answered Dec 29, 2022 at 6:38
Hello,
I am new to JavaFx and I am using it in Intellij IDEA along with JDK 11 and JavaFx 13 .
Iam getting the following error
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found
VM Options: —module-path ${PATH_TO_FX} —addmodules=javafx.controls,javafx.fxml,javafx.base
Default auto-generated code from intellij IDEA
Main.java
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Controller.java
package sample;
public class Controller {
}
If you are new to java and compiling your newly created program, you must be getting an error occurred during initialization of boot layer. The error is very common among the users who have just started with java, eclipse, or Hadoop. Multiple things need to be considered while compiling programs. The error doesn’t have any specific cause that can be pinpointed, user mistake is one of the major causes behind this issue. But no need to be worried. In this troubleshooting guide, we will be going through most of the scenarios and methods in which a user faces error.
Causes of Error Occurred During Initialization Of Boot Layer Problem
Talking of the possible causes behind this error. The error is common among java and eclipse usage. Although multiple users have reported that the error appears because of the java version you are using. Users have found that the 12.x version is not suitable. Furthermore, the issue is also related to classes, paths, and various other things. Users have also reported that the error occurs because Netbeans is turned on.
- Java Version Issues
- Classes, Classpath issues
- Netbeans Turned On
Similar Types of Error Occurred During Initialization Of Boot Layer Issue
- Sdkmanager
- Intellij
- Java.lang.module.findexception eclipse
- Java.lang.module.findexception: unable to derive module descriptor
- Java.lang.module.findexception: module java.activation not found
- An error occurred during initialization of VM
- Com.beust.jcommander.1.72.0: invalid module name: ‘1’ is not a java identifier
- Java.lang.module.findexception: module java.transaction not found
- Module javafx.controls not found
- Java lang module findexception module JDK hotspot agent not found
Below we have tried to cover mostly all the ways to fix this error.
1. Use Java Version Below 12.x
As reported by multiple users and one of the major reasons behind error occurred during initialization of boot layer java.lang.module.findexception: Multiple users have recommended Java 10 or Java 8 instead of Java 12. Java 12 has compatibility issues and very much to such errors.
- STEP 1. To download Java 8, open up your browser and open this link
- STEP 2. Below click on the red Download button, the download will start in a few seconds
- STEP 3. Once downloaded, install it
2. Use Command to Run Java Program
Another error occurred during initialization of boot layer java issue that comes into existence is when the user doesn’t use a command prompt to execute java codes especially if you are working with eclipse. It becomes easier to track whether the issue is with the eclipse or your java code. So it is recommended using the command prompt. Below is a little example.
- STEP 1. Open up a command window and head to where you have saved your .java program
- STEP 2. Supposes it in C: and the name of the program is MyFirst
- STEP 3. Now execute the below command to compile the code
javac MyFirst.java
- STEP 4. If there are no errors that mean, there is no issue with your java code
- STEP 5. Now after executing the above the path variable is set now
- STEP 6. To run the program execute the command below
java MyFirst
- STEP 7. Once you execute the command you will see the result on your screen
3. Turn OFF the ‘Compile on Save’
Another way users have found to eliminate the error is by turning off the ‘Compile on Save’ option in Netbeans. Users have reported that if it is turned on the eclipse error occurred during initialization of boot layer java.lang.module.findexception: module error seems to appear.
- To turn it off, head to, Project Properties > Build > Compiling
4. Miscellaneous Fixes
There are some other fixes as well, that are suggested by users, kindly go through the error occurred during initialization of boot layer eclipse guide, and check if it is working for you.
- While executing selenium codes, try removing the selenium dependencies from the ModulePath to ClassPath under Build path in eclipse
-
Users have also fixed the issue by reordering the source folder. Put it above the JRE System Library. Under Properties > Java Build Path
- Another way users have eliminated the error is by deleting all other classes except the class in which you have written your code. It can be done by going to the PROJECT folder > src > Default package
Conclusion:
In the above troubleshooting guide, we have demonstrated all the ways by which Error Occurred During Initialization Of Boot Layer can be eliminated. We have tried to cover the maximum ways to fix the issue. If you have some other way to fix the issue tell us in the comments.
For more guides and tips follow us. Thank you!
Automation
Introduction
The exception java.lang.module.InvalidModuleDescriptorException is caused by an unnamed package not allowed in a module.
Error
Error occurred during initialization of boot layer java.lang.module.FindException: Error reading module: F:eclipse-workspaceSamplebin Caused by: java.lang.module.InvalidModuleDescriptorException: SampleClass.class found in top-level directory (unnamed package not allowed in module)
Fixes
Check the JDK version of the project. InvalidModuleDescriptorException is a runtime exception usually thrown when reading module descriptor.
# Refactor the code
If we want the project to be as Java module, then we need to refactor the code. The above error occurs when Java classes are created right under the default src default package folder. The unnamed package is not allowed in the module with the latest JDK.
We must declare a named package because this compilation unit is associated to the named module.The name of the module can be found in module-info.java during the project creation phase. To avoid this kind of exception, move all the classes that are in the default package to some named packages.
Create a Package.
Steps to create a new package in Eclipse IDE
Refactor the code to move the classes in unnamed packages to named ones.
# Module descriptor file
If you still see the error:
Check the module descriptor file module-info.java . This file contains the metadata for the module dependencies, packages exports, etc.
# Not a Java Module
If we don’t want the project to be a Java module then simply delete the module-info.java module descriptor file to fix this error.
—
Java Tutorial on this website: https://www.testingdocs.com/java-tutorial/
For more information on Java, visit the official website :
https://www.oracle.com/in/java/
При попытке запустить Java-проект возникает следующая ошибка:
Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package jdk.internal.jrtfs in both module java.base and module jrt.fs
Я попытался удалить JDK и JRE и снова установить их, но проблема все еще существует.
Может кто-нибудь объяснить, как решить эту проблему?
Может ли восстановление системы помочь?
У вас много установки jdk?
— Issam EL-GUERCH
20.09.2018 15:51
@Issam EL-GUERCH, Только один, 10.0.2
— user300045
20.09.2018 15:53
Вы можете разместить свой код?
— Matt
20.09.2018 16:04
Когда вы добавляете внешний файл .jar в новую пользовательскую библиотеку, обязательно отметьте «Путь к загрузочному классу системы».
— SidPro
01.03.2021 09:36
Версия Java на основе версии загрузки
Если вы зайдете на официальный сайт Spring Boot , там представлен start.spring.io , который упрощает создание проектов Spring Boot, как показано ниже.
Принципы SOLID — лучшие практики
SOLID — это аббревиатура, обозначающая пять ключевых принципов проектирования: принцип единой ответственности, принцип «открыто-закрыто», принцип…
Ответы
5
Я столкнулся с той же проблемой, я думаю, что это как-то связано с более новой версией Java.
При создании нового java-проекта вот картина
Щелкните версию 1.8, а затем сохраните ее, и она должна работать.
Если ваша программа работает в командной строке, проблема не в установках JDK, а в среде IDE, которой является Eclipse. попробуйте переустановить Eclipse IDE.
Сегодня я столкнулся с той же проблемой, и я попробовал «Запуск от имени -> Java-приложение». Потом это было исправлено. (кстати, я использовал jdk-11.0.2)
Надеюсь, вы найдете это полезным!
Это может произойти, если у вас есть конфигурация запуска без настроенного проекта и основного класса. Вы можете исправить это, перейдя в настройки запуска и удалив пустую конфигурацию или выбрав правильную при запуске.
Я была такая же проблема. Похоже, что зависимости от Modulepath перепутались. — перекомпоновка проекта после удаления файла Launch Configuration проекта из папки.
…workspace.metadata.pluginsorg.eclipse.debug.core.launches и удаление каталога bin устранили проблему.
Другие вопросы по теме
#java #spring #module #java-11
Вопрос:
Я читал сообщения в StackOverflow почти 1 час, и никакие решения для меня не работали. Я провожу весенний курс для начинающих, используя Eclipse и JDK11. И у меня возникает следующая ошибка в терминале:
An error occurred during initialization of boot layer
java.lang.module.FindException: Module proyectoSpringUno not found
это мой файл java:
package es.pildoras.IoC;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class UsoEmpleados {
public static void main(String[] args) {
ClassPathXmlApplicationContext contexto = new ClassPathXmlApplicationContext("applicationContext.xml");
Empleados Juan = contexto.getBean("miEmpleado",Empleados.class);
System.out.println(Juan.getTareas());
contexto.close();
}
}
У меня есть ошибка при импорте, которая гласит:
The type org.springframework.context.support.ClassPathXmlApplicationContext is not accessible
Я знаю, что эта ошибка возникает, потому что я использую систему модулей java, и если я использую java 8, все эти проблемы исчезнут, но меня не интересует это решение, так как я хочу научиться использовать Spring с более новыми Java JDK.
На данный момент все мои библиотеки добавлены в Путь к классу, но не в Путь к модулю.
Решение, которое я попробовал:
Добавление библиотек в путь к модулю. Результат: это не работает. Когда я добавляю библиотеки в путь к модулю, Eclipse удаляет библиотеки из пути к классам ( вероятно, чтобы избежать дублирования). Теперь у меня нет никаких проблем с информацией о модуле (автомодули, вставленные eclipse) или импортом, но при запуске приложения у меня возникает следующая ошибка:
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:UsersStephaneDesktopcurso SpringProyectoSpringUnolibsspring-context-indexer-5.3.6-sources.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.springframework.context.index.processor.CandidateComponentsIndexer not in module
это информация о модуле:
module ProyectoSpringUno {
exports es.pildoras.IoC;
requires spring.context; // this is automaticly added by eclipse when i add libs to the modulepath
}
Возобновление
- Когда я добавляю свои зависимости в путь к модулю, Eclipse не работает, потому что он хочет, чтобы это было в пути к классу.
- When I add my dependencies to the classpath, eclipse say I need to move some dependencies to the modulepath or the module-info will not work.
- And eclipse don’t let me add them to both modulepath and classpath because they are duplicates.
Any idea on how to fix this?