番石榴上的 ClassNotFoundException
ClassNotFoundException on Guava
我收到一个错误
java.lang.ClassNotFoundException: com.google.common.net.InternetDomainName
尝试运行以下代码时:
private String getTopPrivateDomain(String url) {
return InternetDomainName.from(url).topPrivateDomain().toString();
}
我已经下载 guava-18.0.jar
并且我已经三重检查它是否存在于我的构建路径中。我还导入了 com.google.common.net.*
。我在 Eclipse 中没有收到任何错误或警告,程序编译正常,但当方法为 运行.
时会抛出上述异常
我不明白为什么在明确导入并在构建路径中时找不到 class?
jar 在 运行 时不在类路径位置,但它是在 Eclipse 中配置的。如果你使用 Tomcat 或类似的东西,它需要在 /lib 目录中
我收到一个错误
java.lang.ClassNotFoundException: com.google.common.net.InternetDomainName
尝试运行以下代码时:
private String getTopPrivateDomain(String url) {
return InternetDomainName.from(url).topPrivateDomain().toString();
}
我已经下载 guava-18.0.jar
并且我已经三重检查它是否存在于我的构建路径中。我还导入了 com.google.common.net.*
。我在 Eclipse 中没有收到任何错误或警告,程序编译正常,但当方法为 运行.
我不明白为什么在明确导入并在构建路径中时找不到 class?
jar 在 运行 时不在类路径位置,但它是在 Eclipse 中配置的。如果你使用 Tomcat 或类似的东西,它需要在 /lib 目录中