线程“main”中的异常 java.lang.NoClassDefFoundError: (错误名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13994613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:40:44  来源:igfitidea点击:

Exception in thread "main" java.lang.NoClassDefFoundError: (wrong name

javapackaging

提问by Aditya Yada

my project is in "\BankPrj" folder It has

我的项目在“\BankPrj”文件夹中

(1).com folder

(1).com文件夹

(2)Account.java,Customer.java,TestBanking.javafiles

(2) Account.java, Customer.java,TestBanking.java文件

(3) main class is in TestBanking.java

(3) 主类在 TestBanking.java

this is the error..

这是错误..

enter image description here

在此处输入图片说明

this is my complete project

这是我的完整项目

https://docs.google.com/folder/d/0BzMe2Ya7vhrAem5rcEljc3k1cFE/edit

https://docs.google.com/folder/d/0BzMe2Ya7vhrAem5rcEljc3k1cFE/edit

pls correct the errors.

请更正错误。

i executed TestBanking.class from test folder itself.

我从测试文件夹本身执行了 TestBanking.class。

回答by muruga

Your package is com.mybank.test

你的包裹是 com.mybank.test

The way you should invoke is that go to Folder BankPrj.

您应该调用的方式是转到文件夹 BankPrj。

now do java -classpath . com.mybank.test.TestBanking

现在做 java -classpath 。com.mybank.test.TestBanking

This should work now.

这现在应该可以工作了。

Remember, you cannot go into the leaf of the folder to execute your class. You should always stay at the root (when using the package) and execute with fully qualified package name and the class name to execute it.

请记住,您不能进入文件夹的叶子来执行您的类。您应该始终留在根目录(使用包时)并使用完全限定的包名和类名执行以执行它。

Hope this helps!

希望这可以帮助!