Java 中的 NoClassDefFoundError:com/google/common/base/Function

Java 中的 NoClassDefFoundError:com/google/common/base/Function

问题描述:

当我执行以下代码时:

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());
    }
}

我面临以下错误:

错误:[Ljava.lang.StackTraceElement;@80f4cb

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

线程main"中的异常 java.lang.NoClassDefFoundError: com/google/common/base/Function

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


有人可以帮我找到解决方案或原因吗?


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

我也遇到了同样的问题,最后发现忘记添加selenium-server-standalone-version.jar.我只添加了客户端 jar,selenium-java-version.jar.

I had the same problem, and finally I found that I forgot to add the selenium-server-standalone-version.jar. I had only added the client jar, selenium-java-version.jar.

希望这会有所帮助.