Have been trying to install Protocol Buffers compiler and java runtime installation, but I'm getting an error when compiling the java classes. I downloaded:
protoc-3.2.0rc2-linux-x86_64.zip (although it says the version is 2.6.1)
protobuf-java-3.2.0rc2.zip
The file structure looks like this:
- project/
- protobuf_dir/
- the protobuf files/directories including src/ and java/
- src/
- protoc (binary)
- protoc_dir/ (the other bits and bobs from protoc zip file)
- java/
- core/
- lite/
- ...
- protobuf_dir/
So assuming that's all fine, I typed in:
protoc --java_out=src/main/java -I../src \../src/google/protobuf/descriptor.proto
So protoc seems to be working fine. But then I kept getting errors like these until I commented them out (not sure if that is a problem?):
google/protobuf/descriptor.proto:443:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:443:12: Expected field name.
google/protobuf/descriptor.proto:541:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:541:12: Expected field name.
But when I try compiling all the java classes, I just keep getting an error saying:
Descriptors.java:1175: error: cannot find symbol
return FieldDescriptorProto.Type.forNumber(ordinal() + 1);
Any ideas on how to solve the problem? Can't see why it shouldn't compile. Tried looking on Google's page but nothing comes up on this.
Aware I sound a bit clueless although I've never really used libraries like protobuf from Github before so this is all new to me!
EDIT: Hi all, this issue was resolved with exactly the same file structure. I uninstalled protoc2.6.1, set my $JAVA_HOME and $PATH variables (you should store them too rather than having to export them every time), installed maven (properly).
All is well! Everything compiled without a hitch. Thanks to the responder!