Facing 'Exception in thread "main" java.lang.NoClassDefFoundError"' exception in intellij
import org.testng.annotations.Test;
public class FistTestCase
{
@Test
void setup()
{
System.out.println("Open browser");
}
@Test
void login()
{
System.out.println("This is login test");
}
@Test
void teardown()
{
System.out.println("Close browser");
}
}
Whenever you compile your code, you end up with
.classfile extension for every class that is required in that program. These.classfiles are binary files of the actual classes. TheNoclassfounddeferror arrives when the class loader isn't able to find the package in your main directory. So this means, that the classpath doesn't include all the required packages to run the code. Just check out whether this file is at a correct directory ideally somewhere around main class or in a subdirectory.