1

I'm working with another system library in Eclipse. One time, the library got somehow removed and eclipse showed a red "!" next to the projects folder icon. I re-imported the library, but there is still the red "!". Once I try to compile and run a program, it gives me a "ClassNotFoundException".

Exception in thread "main" java.lang.NoClassDefFoundError: MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
    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)

My java file:

public class MyClass {

    public static void main(String[] args) {
        System.out.println("Test");
    }

}

I don't see any mistakes in my source code. What is going on?

7
  • there is a view called problems view and you can see the errors in there, mostly it is a classpath related error Commented Mar 23, 2013 at 15:17
  • check the classpath, you can find the error there Commented Mar 23, 2013 at 15:17
  • Where your .class files are being saved? Have you set the classpath ? Commented Mar 23, 2013 at 15:21
  • 1
    In eclipse rightclick on project-->properties-->java build path-->remove the old library and add new one Commented Mar 23, 2013 at 15:22
  • @Pragnani make that an answer, you deserve the points Commented May 17, 2013 at 0:23

2 Answers 2

4

Converting Comments as Answer

In eclipse rightclick on project-->properties-->java build path-->remove the old library and add new one

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

1 Comment

Thanks for making it official ;)
0

Go the the Package Explorer, scroll up and right click on the name of your project (that must appear with a red cross) and then select refresh.

I was sorted out using that method. I hope it will help you.

1 Comment

This was answered 6 months ago already, but thanks. (how did you even find this question?)

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.