'Stuck at Running TestNG test cases through command line in windows [TestNG] [ERROR] Cannot instantiate class

I wanted to integrate my automation project to jenkins for daily scheduled jobs, the code is completely written using testng annotations. for that i have created .bat file with required settings. since it is maven project there is no generation of lib or bin so i have pointed class path to target folder.

The error is

[TestNG] [ERROR] Cannot instantiate class [packagename].ApiAutomation.[className]

From the above error i have just used random names in the brackets, in brackets actually it contains the relevant package name or folder etc

java -cp C:\Users[user]\Desktop\automation[folderName]\Final\ApiAutomation\lib*;target\classes;target\test-classes org.testng.TestNG testng.xml

Please help me out....



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source