JNI error. Check the installation
I am trying to run a very simple test using TestNG, but I am getting this error message. I've tried reading the previous answers, but it doesn't work for me. I would be happy if someone could help me as I am just new to TestNG. This error message:
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
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: com.beust.jcommander.ParameterException
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)
... 7 more
source to share
Yes, it issues to testNG
work on the eclipse. In this post, you can try a workaround to fix your error by adding a jcommander jar file to your build path and then start your testNG
eclipse suite.
If you want to start using command line or terminal, here is how to do it on MAC -
java -cp "PATH/TO/TESTNG.jar:PATH/TO/jcommander-1.7.jar" org.testng.TestNG testng.xml
Similarly, replace your path for windows as well, and your test package will run without error using the command line.
source to share
See https://github.com/cbeust/testng-eclipse/issues/140 .
Add jcommdar.jar to your classpath and then run: java -cp "C: \ TestNG \ testng.jar; C: \ TestNG \ jcommander.jar" org.testng.TestNG testng.xml
source to share
To overcome this problem, we need to download the jar file jcommander1.7. to download jar file go under url and get jcommander1.7 jar file
http://www.java2s.com/Code/Jar/j/Downloadjcommander17jar.htm
Jcommander1.7 jar file implementation process-
Right click on project-> Properties-> click on liabraries-> click on Add external jars-> and navigate to the folder where the jcommander1.7 jar file is downloaded.
and run your script, now your script will run successfully.
source to share
I also got the same error when I tried to run the DemoTest.xml file as TestNG Suite
using the Eclipse IDE.
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)
... 7 more
For me the problem was solved when testng-6.11.jar was added to the project build path. Follow these steps:
Right click on project
→ Build path
→ Configure build path
→ Libraries tab
→ Add external jars
jar files → Select testng-6.11.jar and apply
.
source to share