简体   繁体   中英

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

It comes with a ListPeople.java and AddPerson.java file along with a bunch of imports. The problem is that i am getting "The import com.example cannot be resolved" as seen in this screenshot:

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?

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

You're trying to add Java source files as if they're libraries - they're not.

Add the "src" directory as a Source Path (leftmost tab in the Java Build Path settings) instead. 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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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