- Helidon SE Quickstart
This guide describes a basic example of an Helidon SE application using Docker and Kubernetes.
What You Need
For this 5 minute tutorial, you will need the following:
| Java SE 21 (Open JDK 21) | Helidon requires Java 21+ (25+ recommended). |
| Maven 3.8+ | Helidon requires Maven 3.8+. |
| Docker 18.09+ | If you want to build and run Docker containers. |
| Kubectl 1.16.5+ | If you want to deploy to Kubernetes, you need kubectl and a Kubernetes cluster (you can install one on your desktop. |
java -version
mvn --version
docker --version
kubectl version# On Mac
export JAVA_HOME=`/usr/libexec/java_home -v 21`
# On Linux
# Use the appropriate path to your JDK
export JAVA_HOME=/usr/lib/jvm/jdk-21Generate The Project
Generate the project sources using the Helidon Maven archetype. The result is a simple project that shows the basics of a Helidon SE application using simple WebServer routing rules.
mvn -U archetype:generate -DinteractiveMode=false \
-DarchetypeGroupId=io.helidon.archetypes \
-DarchetypeArtifactId=helidon-quickstart-se \
-DarchetypeVersion=4.3.3 \
-DgroupId=io.helidon.examples \
-DartifactId=helidon-quickstart-se \
-Dpackage=io.helidon.examples.quickstart.seIf you are using an earlier version of Helidon and the above command fails with java.lang.NoSuchMethodError then you can work-around the error by replacing archetype:generate with org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate. Or use the helidon CLI.
helidon init --batch -Dflavor=mp -Dapp-type=quickstartThe archetype generates a Maven project in your current directory (for example, helidon-quickstart-se). Change into this directory.
cd helidon-quickstart-seIf you want to use the generated project as a starter for your own application, then you can replace groupId, artifactId and package with values appropriate for your application.
mvn packageThe project builds an application jar for the example and saves all runtime dependencies in the target/libs directory. This means you can easily start the application by running the application jar file:
java -jar target/helidon-quickstart-se.jarThe example is a very simple "Hello World" greeting service. It supports GET requests for generating a greeting message, and a PUT request for changing the greeting itself. The response is encoded using JSON. For example:
curl -X GET http://localhost:8080/greet
{"message":"Hello World!"}
curl -X GET http://localhost:8080/greet/Joe
{"message":"Hello Joe!"}
curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting
curl -X GET http://localhost:8080/greet/Jose
{"message":"Hola Jose!"}Health and Metrics
Helidon provides built-in support for health and metrics endpoints.
curl -sv -X GET http://localhost:8080/observe/healthNotice we use the -v option to curl so that you can see that the health endpoint returns 204 (No Content) by default.
curl -s -X GET http://localhost:8080/observe/metricscurl -H 'Accept: application/json' -X GET http://localhost:8080/observe/metricsBuild a Docker Image
The project also contains a Dockerfile so that you can easily build and run a Docker image. To build the Docker image, you need to have Docker installed and running on your system.
docker build -t helidon-quickstart-se .docker run --rm -p 8080:8080 helidon-quickstart-se:latestThen you can try the application as you did before.
Deploy the application to Kubernetes
If you don’t have access to a Kubernetes cluster, you can install one on your desktop. Then deploy the example:
kubectl cluster-info
kubectl get nodeskubectl create -f app.yaml
kubectl get pods # Wait for quickstart pod to be RUNNINGThe step above created a service that is exposed into any node port. Lookup the service to find the port.
kubectl get service helidon-quickstart-seNote the PORTs. You can now exercise the application as you did before but use the second port number (the NodePort) instead of 8080. For example:
curl -X GET http://localhost:31431/greetAfter you’re done, cleanup.
kubectl delete -f app.yamlBuilding Native and Custom Runtime Images
Helidon also includes support for GraalVM Native Images and Java Custom Runtime Images. For more information see:
The Helidon CLI
With the Helidon CLI you can create additional types of Helidon applications and use the "dev loop" to do fast, iterative development. Try it now.