Use the Lattice SDK for gRPC in Java
This page shows how you can install, set up, and use the Lattice SDK for gRPC in Java to get information about an entity in your environment.
Click to go to the gRPC SDK repository. By downloading and/or using, you agree to the terms of use. If you do not agree, do not use the SDK.
Before you begin
Before you install and use the gRPC SDK in Java, do the following:
- Complete the setup steps to generate a valid API bearer token and publish at least one entity to your environment.
- Install a Java Development Kit (JDK). We recommend using the latest version, for example AdoptOpenJDK.
- Install the latest Gradle distribution.
Set up your Java project
For this example, set up a new Java Gradle project. In the following steps, you'll replace the starter code with examples to help you get started with the Lattice SDK.
-
Confirm that you have Gradle installed:
gradle --version
-
Initialize a sample Gradle project:
gradle init
-
Choose the following options when prompted and leave the rest as defaults:
1. Application
- for build type.1. Java
- for implementation language.Java versionWhen prompted to enter a Java version, use the latest default. You must choose Java 8 or higher to use Lattice.
2. Groovy
- for DSL option.
This generates a new Groovy project. Next, you'll replace the existing boilerplate code with examples that interact with your Lattice environment.
Define the SDK dependencies
To install the Lattice SDK in Java, add the following to your app/build.gradle
file.
.
.
.
dependencies {
// For making gRPC requests
implementation 'io.grpc:grpc-netty-shaded:1.65.1'
implementation 'io.grpc:grpc-stub:1.65.1'
implementation 'io.grpc:grpc-util:1.65.1'
// Generic proto definitions
implementation 'com.google.protobuf:protobuf-java:4.27.4'
implementation 'com.google.protobuf:protobuf-java-util:4.27.4'
// The Lattice Java SDK
implementation 'com.anduril:lattice-sdk:1.2.2'
}
When you run your application, Gradle fetches the required dependencies and builds your project.
What's next
- Start building and publishing entities into Lattice.
- Learn how to watch entities, stream specific components, and apply filters.
- See the Lattice sample applications.