Using Lagom with Java and sbt

Before starting, make sure that you have JDK 8 installed and configured. See Lagom documentation for information on verifying your Java version.

The Lightbend Tech Hub Project Starter makes it simple to create your first project. It uses a Lagom Giter8 template to generate a compressed file that contains:

  • A distribution of sbt for building and running your project.
  • A Lagom Hello World project.

Download the project from Tech Hub

Follow these steps to download a project created from the template:

  1. Open the Tech Hub Project Starter.


    The browser downloads a compressed project.

Extract and run the project

After downloading the compressed file from Tech Hub, follow these steps:

  1. Extract the compressed file to a directory of your choice.

    Note: On macOS, if you unzip using Archiver, you also have to make the sbt files executable:

    chmod u+x ./sbt 
    chmod u+x ./sbt-dist/bin/sbt
  2. In a shell, change into the top-level directory of the project, lagom-java-sbt. For example, if you extracted the project into a directory named my-project:

    • In a macOS or Linux shell:
      cd my-project/lagom-java-sbt
    • In a Windows shell:
      cd my-project\lagom-java-sbt
  3. Start sbt and the Lagom development environment:

    ./sbt runAll

    It will take a bit of time to build and run the project. When finished, the console displays the message: Services started, ....

  4. Verify that the services are indeed up and running by invoking the hello service endpoint from any HTTP client, such as a browser: http://localhost:9000/api/hello/World

    The request returns the message Hello, World!.

Congratulations! You've created and run your first Lagom system. See the Lagom documentation to learn more about your new project.