NoClassDefFoundError in Java: com/google/common/ba

2019-01-02 23:47发布

When I executing the following code:

public static void main(String[] args) {
    try {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("http:www.yahoo.com");
    } catch (NoClassDefFoundError ex) {
        System.out.println("error: " + ex.getStackTrace());
    }
}

I'm facing the following error:

error:[Ljava.lang.StackTraceElement;@80f4cb

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function


Could someone help me to find the solution or reason for this?

15条回答
可以哭但决不认输i
2楼-- · 2019-01-03 00:30

After you extract your "selenium-java-.zip" file you need to configure your build path from your IDE. Import all the jar files under "lib" folder and both selenium standalone server & Selenium java version jar files.

查看更多
冷血范
3楼-- · 2019-01-03 00:31

Please include all the jar files of selenium stand-alone and lib folder, then this error will resolved

查看更多
你好瞎i
4楼-- · 2019-01-03 00:31

I wanted to try a simple class outside IDE and stuff. So downloaded selenium zip from website and run the class like this:

java -cp selenium-2.50.1/*:selenium-2.50.1/libs/*:. my/package/MyClass <params>

I had the issue that I initially used lib instead of libs. I didn't need to add selenium standalone jar. This is Java 8 that understands wildcards in classpath. I think java 7 would also do.

查看更多
登录 后发表回答