引导层FindException初始化期间发生错误:找不到模块 [英] Error occurred during initialization of boot layer FindException: Module not found

查看:651
本文介绍了引导层FindException初始化期间发生错误:找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Java 9执行一个简单的"Hello World"程序会导致以下错误消息:

Executing a simple "Hello World" program using Java 9 results in the following error message:

启动层初始化期间发生错误
java.lang.module.FindException:找不到模块com.pantech.myModule

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

我执行的命令行是:

java --module-path bin -m com.pantech.myModule/com.pantech.myModule.HelloWorld

此命令行从我的bin目录的父目录执行,该目录包含所有.class字节码文件.

This command line is executed from the parent directory of my bin directory that contains all of the .class bytecode files.

module-info.class文件位于bin目录中的com.pantech.myModule目录中. HelloWorld.class文件包含main方法,并且位于com.pantech.myModule目录内的包目录中.因此,HelloWorld.class文件的路径名称为 bin \ com.pantech.myModule \ com \ pantech \ myModule \ HelloWorld.class .

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.

HelloWorld类在com.pantech.myModule程序包中(程序包名称与模块名称相同).

The HelloWorld class is in the com.pantech.myModule package (package name same as the module name).

我正在使用Windows 10作为操作系统.从我已阅读的所有内容来看,以上命令行应该是正确的.有关如何解决此问题的任何建议?

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?

推荐答案

其背后的原因是,在创建自己的类的同时,您还同意按照IDE的规定并在将代码编写后创建默认类.自己的课程,您会收到这样的错误.为了消除这种情况,请转到PROJECT文件夹→src→默认程序包.仅保留一个类(您已经在其中编写了代码),并删除其他类.

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.

这篇关于引导层FindException初始化期间发生错误:找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆