user8897013
user8897013

Reputation: 463

How to compile protocol buffer java classes from a prototxt file

Are prototxt file compilable? Are these really the same as the .proto files?

I have read What's the different between .proto and .prototxt file and this corresponding link and also this, however no where does it describe what do with the prototxt file.

Using: protoc --proto_path=. --java_out=. test.proto I get a test.java file.

However, protoc --proto_path=. --java_out=. test.prototxt (a valid test.prototxt file, not just a renamed .proto file) does not compile. What am I missing and why is this not mentioned anywhere?

Upvotes: 1

Views: 284

Answers (1)

Edwin Buck
Edwin Buck

Reputation: 70949

The first call compiles the protocol structure file into a Java class that can read and write the data.

The second call attempts to compile a saved chunk of data, which is probably in the format that the test.proto describes. You can't compile serialized data into a Java class, you use the Java class from the first command to read the test.prototxt file.

Upvotes: 1

Related Questions