无法找到或加载主类 org.testng.TestNG [英] could not find or load main class org.testng.TestNG
问题描述
我正在尝试以这种方式从cmd`执行testng-qc-sanity-regression.xml:
I'm trying to execute testng-qc-sanity-regression.xml from
cmd` in this way:
runtest.bat testng-qc-sanity-regression.xml
runtest.bat testng-qc-sanity-regression.xml
我得到这个错误:
无法找到或加载主类 org.testng.TestNG
could not find or load main class org.testng.TestNG
但我真的不知道为什么.我试过了:
but I don't really know why. I've tried with:
java -jar myjar.jar -cp ./bin testng-qc-sanity-regression.xml
java -jar myjar.jar -cp ./bin testng-qc-sanity-regression.xml
没用.
我也尝试过:
java -cpD:Profilesuser.m2 epositoryorg estng estng6.8.5 estng-6.8.5.jar;org.testng.TestNG testng-qc-sanity-regression.xml
java -cp D:Profilesuser.m2 epositoryorg estng estng6.8.5 estng-6.8.5.jar; org.testng.TestNG testng-qc-sanity-regression.xml
我在线程main"java.lang.NoClassDefFoundError 中得到异常
.
And I got Exception in thread "main" java.lang.NoClassDefFoundError
.
当我从 Eclipse 执行项目时工作正常,有什么想法吗?
推荐答案
第一条命令:
java -jar myjar.jar -cp ./bin testng-qc-sanity-regression.xml
将尝试执行您在 META-INF/MANIFEST.MF 下的 jar 文件中定义的主类,这不是您想要的.
will try to execute your main class defined in the jar file under META-INF/MANIFEST.MF which is not what you want.
第二条命令
java -cp D:Profilesuser.m2
epositoryorg estng estng6.8.5 estng-6.8.5.jar; org.testng.TestNG testng-qc-sanity-regression.xml
没有在类路径上定义当前目录,路径中也有错字.
is not defining the current directory on classpath and there is also a typo in the path.
尝试使用以下内容:
java -cp ".;D:Profilesuser.m2
epositoryorg estng estng6.8.5 estng-6.8.5.jar" org.testng.TestNG testng-qc-sanity-regression.xml
这篇关于无法找到或加载主类 org.testng.TestNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!