A collection of Java gRPC examples demonstrating various concepts and features of the gRPC framework. Each example is a standalone project designed to showcase a specific aspect of gRPC in Java.
This repository contains a series of Java gRPC examples. Each example focuses on demonstrating a particular concept or
feature of the gRPC framework in Java. The examples are located in the examples
directory.
- Java 21
Each subdirectory within the examples
folder represents a separate gRPC example project. These projects are
independent of one another and can be explored individually.
- example-echo-server: Basic Unary RPC echo server
Each example project includes Gradle tasks to run the gRPC server and client applications.
-
Run the Server
In one terminal window, execute:
./gradlew :example:EXAMPLE_NAME:runServer
-
Run the Client
In a separate terminal window, execute:
./gradlew :example:EXAMPLE_NAME:runClient
Alternatively, you can assemble executable distributions for both the client and server.
-
Assemble Server Distribution
./gradlew :example:EXAMPLE_NAME:assembleDistServer
The distribution will be located in
examples/EXAMPLE_NAME/build/distributions/
. -
Assemble Client Distribution
./gradlew :example:EXAMPLE_NAME:assembleDistClient
The distribution will be located in
examples/EXAMPLE_NAME/build/distributions/
. -
Run the Server
Unzip the server distribution and execute the startup script:
-
On Unix/Linux/Mac:
unzip build/distributions/Server.zip cd Server ./bin/Server
-
On Windows:
unzip build\distributions\Server.zip cd server-distribution .\bin\Server.bat
-
-
Run the Client
Unzip the client distribution and execute the startup script:
-
On Unix/Linux/Mac:
unzip build/distributions/Client.zip cd Client ./bin/Client
-
On Windows:
unzip build\distributions\Client.zip cd Client .\bin\Client.bat
-
Contributions are welcome! Please open an issue or submit a pull request with your improvements.