Implementing services in Java
The following are required to start writing services in Java:
- Java version
Akka Serverless requires at least Java 8, though we recommend using Java 11, which has better support for running in containers. While it is possible to build a GraalVM native image for Java service implementations, at this stage the SDK offers no specific assistance or configuration to aid in doing that.
- Build tool
Akka Serverless does not require any particular build tool, you can select your own.
Since Akka Serverless is based on gRPC, you need a protoc compiler to compile gRPC protobuf descriptors. While this can be done by downloading, installing and running protoc manually, most popular build tools have a protoc plugin which will automatically compile protobuf descriptors during your build.
Akka Serverless runs in Kubernetes using Docker. You will need Docker to build container images that you can deploy to Kubernetes. Most popular build tools have plugins that assist in building Docker images.
- Java support library
See the instructions in Install the SDK library.
As mentioned, you can use the build tool of your choice. The following examples show how to install the Java library for Gradle, Maven, and sbt.
build.gradlefile, add the following:
compile group: 'io.cloudstate', name: 'cloudstate-java-support', version: '0.5.2'
.pomfile, add the following:
<dependency> <groupId>io.cloudstate</groupId> <artifactId>cloudstate-java-support</artifactId> <version>0.5.2</version> </dependency>
In your dependencies file, add the following:
libraryDependencies += "io.cloudstate" % "cloudstate-java-support" % "0.5.2"