Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

selenium - Getting "java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException"Exception

I wanted to invoke testng programmatically. Not eclipse plug-in.

I have associated "testng-6.8.21.jar" and running through eclipse and i ran below code:

import org.testng.TestNG;

public class SampCls 
{
        public static void main(String[] args)
        {
            TestNG test=new TestNG();
        }
}

Getting below exception. How can i overcome this exception.

Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
    at SampCls.main(SampCls.java:12)
Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    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)
    ... 1 more
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you use a Maven project, you need add this dependancy:

<dependency>
    <groupId>com.beust</groupId>
    <artifactId>jcommander</artifactId>
    <version>1.48</version>
</dependency>

the class com/beust/jcommander/ParameterException is inside

If you use a project without Maven you need add this jar file at your classpath:

jcommander-1.48.jar

You can download this jar file on central.maven.org -> jcommander-1.48.jar


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...