3

I'm working with selenium webdriver. I tried so many times to execute my script. It's showing an error again and again. What will I do to resolve? What is the solution for this? I am using eclipse neon and jdk version 8. main method is working fine but @test page is giving me an jni error.. Error is :

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more
  • By adding jcommander-1.48.jar & bsh-2.0b4.jar files to the project, make test running – Golam Hassan Jan 19 '17 at 21:47
3

Understand - Cause why this occur

  • Any of your file is present at the compile time but its not reachable at the execution time

  • You need to crosscheck both compile time and run time environment & class paths

  • 2
    thank you . I got the error.. I added 2 jar files(jcommander,jar & bsh-1.3.0.jar). My program is now running properly.. – user21268 Oct 14 '16 at 10:28
  • 1
    Thanks for the answer, it gave me a hint to solve mine. Have similar situation, perforce were not getting all jars for the project, after mapping project again and importing, all jars appeared and error was gone. To check whether that is the case, one need simply check "Libraries" in "Java Build Path" (Project -> preferences). – Anahit Serobyan Feb 8 '17 at 8:11