首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用OpenCyc的NoClassDefFoundError,可能出了什么问题?

尝试使用OpenCyc的NoClassDefFoundError,可能出了什么问题?
EN

Stack Overflow用户
提问于 2012-04-13 00:36:24
回答 1查看 66关注 0票数 0

我想创建连接到openCyc知识库的cycAccess对象,但我无法创建此对象。我从这段代码中得到了NoClassDefFoundError ...有谁能帮我吗?以下是我的代码..。

代码语言:javascript
复制
public static void exampleConnectingToCyc() {
System.out.println("Starting Cyc connection examples.");
CycAccess access = null;
try {
  access = new CycAccess("localhost", 3602);
  System.out.println("Successfully established CYC access " + access);

  // The following code should only be called if you will be modifying the KB
  // and one should typically use a real user and more specific KE purpose.
  // This information is used for accurately maintaining KB content
  // bookkeeping information.
  CycConstant cycAdministrator = access.getKnownConstantByName("CycAdministrator");
  CycConstant generalCycKE = access.getKnownConstantByName("GeneralCycKE");
  access.setCyclist(cycAdministrator);
  access.setKePurpose(generalCycKE);

  // Do stuff with the connection here.

  // Note: The class CycAccess contains many of the
  // useful public methods for interacting with Cyc.

  // Note: Establishing a connection with Cyc is relatively expensive.
  // If you have a lot of work to do with Cyc over time, make a single
  // CycAccess object and use that everywhere.
} catch (UnknownHostException nohost) {
  // if cyc server host not found on the network
  nohost.printStackTrace();
} catch (IOException io) {
  // if a data communication error occurs
  io.printStackTrace();
} catch (CycApiException cyc_e) {
  // if the api request results in a cyc server error
  // example: cannot launch servicing thread;
  // protocol errors, etc.
} catch (Exception e) {
} finally {
  // ensure that the connection is closed when finished
  if (access != null) {
    access.close();
  }
}
System.out.println("Finished.");

}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-13 00:43:06

NoClassDefFoundError通常意味着在编译时可用的类在运行时不可用。我建议您检查应用程序的类路径,以查看是否所有必需的依赖项都在类路径中。因为大部分代码使用JDK提供的类,所以您可能应该查看CycAccess和CycConstant类所需的依赖项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10127880

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档