Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one generate client and server code manually for Java in gRPC?

The official documentation states the following with respect to generating client and server code.

Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler protoc with a special gRPC Java plugin. You need to use the proto3 compiler (which supports both proto2 and proto3 syntax) in order to generate gRPC services.

Unfortunately, it simply suggests that one uses Maven or Gradle to generate the actual client and server stubs.

What is the actual protoc command line invocation for this generation?

like image 222
merlin2011 Avatar asked Jun 29 '26 03:06

merlin2011


1 Answers

The gRPC Java Codegen Plugin for Protobuf Compiler readme file talks about this:

To compile a proto file and generate Java interfaces out of the service definitions:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
like image 133
Petr Janeček Avatar answered Jul 01 '26 16:07

Petr Janeček



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!