2012-02-02 71 views
0

我不知道如何解决这个问题。我是一个新的eclipse用户。我非常感谢任何帮助。在Eclipse中运行程序时出现问题 - 类路径错误

Exception in thread "main" java.lang.NoClassDefFoundError: test_multiply/Matrix 
Caused by: java.lang.ClassNotFoundException: test_multiply.Matrix 
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 


package test_multiply; 

公共类矩阵{

public static void main (String[] args) { 
    //taking value as command line argument. 
    int num = Integer.parseInt(args[0]); 

    for (int i = 1; i < num + 1; i++) { 
     for (int j = 1; j < num + 1; j++) { 
      System.out.print(i+"*"+j+"="+i * j); 
      System.out.print("\t");   } 
     System.out.println(); 
    } 
} 

}

+0

这个类是否存在? – 2012-02-02 16:06:30

+1

请告诉我们你是如何尝试运行你的班级,它实际上是什么等。 – 2012-02-02 16:06:40

+0

请提供更多的输入,并尝试发布导致此异常的代码。 – Bala 2012-02-02 16:08:51

回答

1

确保您拥有所有必要的jar文件的程序。错误是一个涉及Java,而不是eclipse,所以eclipse不应该与异常有关。

1

基本上,在线程异常“主要” java.lang.NoClassDefFoundError:

意味着,你正在尝试运行的类在classpath.So没有找到,你可以检查类或。 jar文件放入适当的java classpath中。

+0

package test_multiply; 公共类矩阵{ \t公共静态无效的主要(字串[] args){ \t \t //服用值作为命令行参数。 \t \t int num = Integer.parseInt(args [0]); \t \t对(INT I = 1; I user1185549 2012-02-02 19:11:17

0

该错误指出它无法找到test_multiply.Matrix类。其他项目和库可以添加到项目的类路径中,右键单击项目,选择“属性”,然后导航到“Java构建路径”。

相关问题