I am trying to generate java files from below proto file using protobuf nano. I got some basic instruction on how to proceed in this SO thread.
I have this proto file, personal.proto
:
package tutorial; option java_package = "com.example.tutorial"; option java_outer_classname = "AddressBookProtos"; message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } repeated PhoneNumber phone = 4; } message AddressBook { repeated Person person = 1; }
I tried to follow the instruction from here, more specifically NANO version:
- Downloaded
protobuf-2.5.0.zip
and compilerprotoc-2.5.0-win32.zip
from here. - Unzipped
protobuf-2.5.0.zip
to a folder and in there insrc
subfolder I unzippedprotoc.exe
. - Changed to
java
folder and in there issued:mvn clean package -P nano
. That command ran fine and intarget
folder I haveprotobuf-java-2.5.0.jar
From here I am not sure how to proceed since in the initial documentation I have this statement:
- Link with the generated jar file <protobuf-root>java/target/protobuf-java-2.3.0-nano.jar.
I am not sure what that means, how to link? Is there some parameter for protoc.exe
that specifies the jar file to use?
I tried to issue this command: protoc --javanano_out=enum_style=java --java_out=generated personal.proto
but I get this error: --javanano_out: protoc-gen-javanano: The system cannot find the file specified
.
The question would be: what am I missing/doing wrong above? I am trying to generate java files from above proto file.