0

I dont know how to fix this problem. I am a new eclipse user. I really appreciate any help.

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 class Matrix {

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();
    }
}

}

3
  • 1
    Please tell us how you're trying to run your class, what it's actually called etc. Commented Feb 2, 2012 at 16:06
  • Please provide more inputs and try to post the code which causes this exception. Commented Feb 2, 2012 at 16:08
  • possible duplicate of Eclipse and Classpath Commented Feb 2, 2012 at 16:08

3 Answers 3

1

Make sure you have all the necessary jar files for your program. The error is one dealing with Java, not eclipse, so eclipse should not have anything to do with the exception.

Sign up to request clarification or add additional context in comments.

Comments

1

Basically, the Exception in thread "main" java.lang.NoClassDefFoundError:

means, that the class which you are trying to run was not found in the classpath.So you can check if the class or .jar file is into appropriate java classpath.

1 Comment

package test_multiply; public class Matrix { 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

The error states that it can't find the test_multiply.Matrix class. Additional projects and libraries can be added to your project's classpath be right-clicking on the project, selecting "Properties", and then navigating to "Java Build Path".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.