Error: Could not find or load main class org.testng.TestNG

13,217

Try at least to add to classpath:

set classpath=myProjectDirectoryPath/bin
set classpath=%classpath%;myProjectDirectoryPath/lib/*

If not, the second "set" override the first.

Of specify the cp (classpath) directly ni the java command:

java -cp myProjectDirectoryPath/bin;myProjectDirectoryPath/lib/* org.testng.TestNG testng.xml

In both instance, make sure you have a testng.jar in one of those folders.

Share:
13,217
nsd
Author by

nsd

Updated on June 04, 2022

Comments

  • nsd
    nsd about 2 years

    Error: Could not find or load main class org.testng.TestNG

    I used the following steps/commands to run my testNG script through command prompt:

    1. in my project folder, create a lib folder and copy all the jar files
    2. open cmd --> cd myProjectDirectoryPath
    3. set classpath=myProjectDirectoryPath/bin
    4. set classpath=myProjectDirectoryPath/lib/*
    5. java org.testNG.TestNG testng.xml
    

    but after that i am getting Could not find or load main class org.testng.TestNG error. tried to debug but still not successful. can someone help me.