OS X Maverick 上不存在包 com.google.protobuf [英] package com.google.protobuf does not exist on OS X Maverick

查看:173
本文介绍了OS X Maverick 上不存在包 com.google.protobuf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OS X Mavericks 上并开始学习 protobuf,我从 https 下载示例://code.google.com/p/protobuf/downloads/list

I am on OS X Mavericks and starting learning about protobuf, i download the example from https://code.google.com/p/protobuf/downloads/list

我能够成功地从 proto 创建 .java 文件,但同时使用

I am successfully able to create the .java file from the proto but while compiling the existing java code using

make java,出现以下错误

make java, i am getting following error

com/example/tutorial/AddressBookProtos.java:91: package com.google.protobuf does not exist
      com.google.protobuf.GeneratedMessage
                         ^
com/example/tutorial/AddressBookProtos.java:12: package com.google.protobuf does not exist
      extends com.google.protobuf.MessageOrBuilder {
                                 ^
com/example/tutorial/AddressBookProtos.java:9: package com.google.protobuf does not exist
      com.google.protobuf.ExtensionRegistry registry) {
                         ^
com/example/tutorial/AddressBookProtos.java:2495: package com.google.protobuf.Descriptors does not exist
  private static com.google.protobuf.Descriptors.Descriptor
                                                ^
com/example/tutorial/AddressBookProtos.java:2498: package com.google.protobuf.GeneratedMessage does not exist
    com.google.protobuf.GeneratedMessage.FieldAccessorTable
....
....

对此有任何解决方案吗?

Any resolution to this?

谢谢

推荐答案

遇到同样的问题,终于搞定了.这是我在 OSX 10.9 上所做的(使用 2.6.0 版):

Met the same problem and finally got it working. Here's what I did(using version 2.6.0) on OSX 10.9:

  1. java/README.txt告诉你的一切

如果maven package成功,你会在target文件夹下得到一个protobuf-java-2.6.0.jar,对我来说是 /Users/laike9m/Dev/protobuf-2.6.0/java/target/protobuf-java-2.6.0.jar.

if maven package succeed, you'll get a protobuf-java-2.6.0.jar under target folder, for me it's /Users/laike9m/Dev/protobuf-2.6.0/java/target/protobuf-java-2.6.0.jar.

创建~/Library/Java/Extensions文件夹,注意:这是平台特定的操作,对于OSX以外的操作系统应该是$JAVA_HOME/lib/ext代码>

create ~/Library/Java/Extensions folder, note: this is platform specific operation, for OS other than OSX it should be $JAVA_HOME/lib/ext

protobuf-java-2.6.0.jar复制到~/Library/Java/Extensions

那么你应该可以成功运行make java.

Then you should be able to run make java successfully.

这篇关于OS X Maverick 上不存在包 com.google.protobuf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆