简体   繁体   中英

package com.google.protobuf does not exist error while trying to build ProtoBuf Java component

Previously I was able to run make all and make java . I did a make clean after which make java fails with com/example/tutorial/AddressBookProtos.java:95: error: package com.google.protobuf does not exist .

I followed this SO post , but it fails .

examples $protoc --version
libprotoc 3.5.1

examples $make java
make: Nothing to be done for `java'.

examples $make clean
rm -f add_person_cpp list_people_cpp add_person_java list_people_java add_person_python list_people_python
rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/*.class
rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/AddressBookProtos.java
rm -f *.pyc
rm -f protoc_middleman_go tutorial/*.pb.go add_person_go list_people_go
rmdir tutorial 2>/dev/null || true
rmdir com/example/tutorial 2>/dev/null || true
rmdir com/example 2>/dev/null || true
rmdir com 2>/dev/null || true

examples $make java
protoc $PROTO_PATH --cpp_out=. --java_out=. --python_out=. addressbook.proto
javac -cp $CLASSPATH AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
com/example/tutorial/AddressBookProtos.java:95: error: package com.google.protobuf does not exist
      com.google.protobuf.GeneratedMessageV3 implements
                         ^
com/example/tutorial/AddressBookProtos.java:19: error: package com.google.protobuf does not exist
      com.google.protobuf.MessageOrBuilder {

Is there an older version of Protobuf that I can use? Or how can I fix this error.

I got the same errors untill I fixed a typo in $CLASSPATH. It is too sad Javac does not emit better error messages when jar files in classpath do not exist.

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