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

      

+4


source to share


8 answers


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.

+7


source


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

+3


source


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.

+1


source


Add jcommdar.jar

in classpath

and then run:

java -cp "C:\TestNG\testng.jar;C:\TestNG\jcommander.jar" org.testng.TestNG testng.xml

      

It really helped me.

0


source


I had a similar error when running my testng.xml. I replaced my selenium server that was included (build path) by a local user from his local path. Copy the jar files to your project (lib) folder and include them in your project. This worked for me.

0


source


This usually happens when your JDK version and JRE version are not compatible, or when the required JRE version is not installed.

To fix the error, use Window -> Preferences -> Compiler -> Compiler Compliance Level and change the JRE version to your existing JRE version.

0


source


I also got the same error when I tried to run the DemoTest.xml file as TestNG Suite

using the Eclipse IDE.

enter image description here

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

.

0


source


I got this problem after uninstalling my new java jdk version and upgrading to the old java jdk version.

I solved this by recreating my java project in eclipse.

-1


source







All Articles