Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNGException - Error in Eclipse

Open 1 Answers 31 Views
I trying to run testng with eclipse and I am getting this error

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNGException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.testng.TestNGException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Is there any solution for this?

1 Answer


It looks like TestNG libraries are not properly added to your build path:

If you are using Eclipse,

In Eclipse> Project > Clean

In case of IntelliJ

Go to configuration tab in TestNG "Run/Debug Configurations and select "In the whole project".

Also, if you are using maven, download all dependencies again and update your dependency tree.

answered Jul 14 by stbadmin (4,970 points)