简体   繁体   English

导入com.example无法解析

[英]The import com.example cannot be resolved

I am trying to compile this example given by Google on the protocol buffers: https://developers.google.com/protocol-buffers/docs/javatutorial 我正在尝试编译Google在协议缓冲区上给出的这个示例: https//developers.google.com/protocol-buffers/docs/javatutorial

It comes with a ListPeople.java and AddPerson.java file along with a bunch of imports. 它附带了一个ListPeople.java和AddPerson.java文件以及一堆导入。 The problem is that i am getting "The import com.example cannot be resolved" as seen in this screenshot: 问题是我得到“导入com.example无法解析”,如此截图中所示:

http://postimg.org/image/67whg6a57/full/

This is the full path of the import com.example java file:
http://postimg.org/image/wexoc4sez/full/

and where all of my files are located:
http://postimg.org/image/4veseacpn/full/

I've tried to do the following: 我试过做以下事情:

Project->Clean
File->Refresh
Property->Java build path->add external JAR:
http://postimg.org/image/xjrqhievv/full/

None of these has work. 这些都没有用。 What is the problem? 问题是什么?

So this seems to be code that is missing from your project. 所以这似乎是您的项目中缺少的代码。 If you press Shift-Ctrl-T and type in AddressBook, is it there? 如果您按Shift-Ctrl-T并键入AddressBook,它是否存在?

If it is not there then it has not been generated from the example .proto files as specifiied in the Google on the protocol buffers files 如果它不存在,那么它尚未从示例.proto文件中生成,如Google on the protocol buffers文件所指定的那样

You're trying to add Java source files as if they're libraries - they're not. 您正在尝试添加Java 文件,就像它们是库一样 - 它们不是。

Add the "src" directory as a Source Path (leftmost tab in the Java Build Path settings) instead. 添加“src”目录作为源路径(Java Build Path设置中最左侧的选项卡)。 Or if that's already a source path, try refreshing it in package explorer. 或者,如果它已经是源路径,请尝试在包资源管理器中刷新它。 Either way, you definitely don't want to have source files as libraries... 无论哪种方式,你绝对不希望将源文件作为库...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM