I'm new to protobufs and was trying to learn more about using them. I've downloaded the protobuf packaged from here. There is a README.txt file inside the examples folder of the archive which gives instructions on how to build 2 example applications. However when I follow those instructions for building the java application:
make java
I get a lot of errors followed by:
100 errors
make: * [javac_middleman] Error 1
All of the 100 errors seem to be classpath related, as this is a typical example:
com/example/tutorial/AddressBookProtos.java:37: error: package com.google.protobuf does not exist
Any ideas about how to get passed this?
The problem is that for some reason protobuf
jar is not added to the classpath during compilation. To fix it you should open examples/Makefile
and add -cp protobuf-java-2.4.1.jar
at the end of java complilation line javac AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
.
P.S. If you built you protobufs with maven the jar is located at ~/.m2/repository/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar
(version of the jar might be different)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With