【问题标题】:Exception when trying to update twitter status using java尝试使用 java 更新 twitter 状态时出现异常
【发布时间】:2013-08-29 16:06:20
【问题描述】:

我正在尝试使用带有此库的 java 更新状态:https://code.google.com/p/java-twitter/

还有这段代码:

Api api = Api.builder().username("username").password("password").build();
api.updateStatus("Just test").build().post();

但是当我运行应用程序时会发生此异常:

exception in thread "main" java.lang.NoClassDefFoundError: com/google/protobuf/Descriptors$FileDescriptor$InternalDescriptorAssigner
    at net.unto.twitter.UtilProtos$Url$Scheme.<clinit>(UtilProtos.java:83)
    at net.unto.twitter.Api.<clinit>(Api.java:97) 

有什么帮助吗?

从 java 发布推文的最简单方法是什么?

谢谢。

【问题讨论】:

  • 您确定您已获取完整的 ProtoBuf 库并将其放在类路径中吗?
  • 我只是下载了 java-twitter-0.9-SNAPSHOT.jar 并将其添加到类路径中

标签: java twitter


【解决方案1】:

您缺少 protobuf 库。从here 下载它们并将其也放入您的类路径中。

【讨论】:

  • 我下载了它,但另一个例外来了!线程“主”java.lang.NoSuchMethodError 中的异常:com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Ljava/lang/String;[Lcom/google/protobuf/Descriptors$FileDescriptor;Lcom/google/protobuf/Descriptors$FileDescriptor $InternalDescriptorAssigner;)V at net.unto.twitter.UtilProtos.(UtilProtos.java:598) at net.unto.twitter.UtilProtos$Url$Scheme.(UtilProtos.java:83) at net. to.twitter.Api.(Api.java:97)
  • @user2728312 首先不用惊呼。其次,为什么您不能编辑堆栈跟踪实际上是可读的原始帖子?
【解决方案2】:

仅下载 java-twitter jar 并将其添加到您的类路径是不够的。 该库具有运行时依赖项。项目页面上提供了列表,link

您需要确保在类路径上拥有所有运行时依赖项,以便能够使用该库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 1970-01-01
    • 2017-10-20
    相关资源
    最近更新 更多