3

I just run a simple test with testNG(version 6.8). All code is like this.

import org.testng.annotations.*;
public class TestNGtest {
    @Test
    public void test(){
        System.out.print("123");
    }
}

I run it but it returns :

Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:119)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

BUT there is jcommander.jar in my classpath(in my java/jre/lib) already. someboby has the same problem?

It is a maven project, i have added jcommander ,testng dependencies in my pom.xml ; these code is all fine when run on other computers ,but only throws this error on my computer(i cloneed it from git). Can anybody help me?

inlusion
  • 31
  • 1
  • 3
  • Does this answer your question? https://stackoverflow.com/questions/30435688/getting-java-lang-noclassdeffounderror-com-beust-jcommander-parameterexception – Rahul Raj Aug 28 '17 at 05:42
  • There is something wrong with your parameter. Should be **@Test()**. If there is a problem see this link. https://stackoverflow.com/questions/30435688/getting-java-lang-noclassdeffounderror-com-beust-jcommander-parameterexception – Kyaw Kyaw Aug 28 '17 at 05:46
  • the question you linked does not work for me . and it's not sth wrong with my parameter,i tried @Test(description = "tttttt"),but it's the same. i ran the same code on another computer,and it's fine . so i'm comfused .... – inlusion Aug 28 '17 at 06:02
  • Sorry. You should learn this page. https://stackoverflow.com/questions/17973970/how-to-solve-java-lang-noclassdeffounderror. I hope this may help you. – Kyaw Kyaw Aug 28 '17 at 06:43

1 Answers1

0

Download jcommander jar file from the maven repository and add it to the dependencies just like testng jar file

Go to projectstructure->Modules->depenencies->add jcommander jar file-> click apply

dependencies in projectStructure