[英]How to solve Exception in thread “main” java.lang.NoClassDefFoundError
I am installing eclipse in my mac and just try to test this code but show the error "Exception in thread "main" java.lang.NoClassDefFoundError" How i can solv or fixed it? 我正在Mac中安装eclipse,只是尝试测试此代码,但显示错误“线程“主”中的异常” java.lang.NoClassDefFoundError”我如何解决或修复它?
import java.util.*;
import java.io.*;
public class MyMain
{
public static void main(String[] args)
{
//System.out.println("Hello world");
}
}
In eclipse select this menu: Run > Run Configurations... 在Eclipse中,选择以下菜单: 运行 > 运行配置...。
Then select the Run configuration of your test code. 然后选择测试代码的“运行”配置。
In the Main class field check what's written there... If the class MyMain
has no package, Main class field should contain "MyMain". 在“ 主类”字段中检查其中写的内容...如果类
MyMain
没有包,则“ 主类”字段应包含“ MyMain”。
This class should compile and work if the file is called MyMain.java. 如果该文件名为MyMain.java,则该类应编译并运行。 to compile it just run
javac MyMain
from the same directory the file is located. 要编译它,只需从文件所在的目录运行
javac MyMain
。 Then run java MyMain
and you are good. 然后运行
java MyMain
,您就很好了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.