Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problems building the protobuf example apps

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?

like image 238
klactose Avatar asked Feb 20 '13 19:02

klactose


1 Answers

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)

like image 104
jonasnas Avatar answered Oct 08 '22 19:10

jonasnas