You can create your getting-started project by using the Quarkus command-line interface (CLI).

With the Quarkus CLI, you can create projects, manage extensions, and run build and development commands.

Important: The Quarkus CLI is intended for development purposes, including tasks such as creating, updating, and building Quarkus projects. However, IBM does not support using the Quarkus CLI in production environments.

Prerequisites
Procedure
  1. To generate the project, in a command terminal, enter the following command:

    quarkus create && cd code-with-quarkus

     

    Note: You can also specify the 'app' subcommand, for example, quarkus create app. However, it is not mandatory to do so because the 'app' subcommand is implied if it is not specified.

    With this command, you create the Quarkus project in a folder called code-with-quarkus in your current working directory.

  2. By default, the groupId, artifactId, and version attributes are specified with the following default values:

    • groupId='org.acme'

    • artifactId='code-with-quarkus'

    • version='1.0.0-SNAPSHOT'

      To change the values of the groupId, artifactId, and version attributes, issue the quarkus create command and specify the following syntax on the CLI:

      groupId:artifactId:version

      For example, quarkus create app mygroupId:myartifactid:version

    Note: To view information about all the available Quarkus commands, specify the help parameter:

    quarkus --help
  3. Review the src/main/java/org/acme/GreetingResource.java file in a text editor:

    package org.acme;
    
    import jakarta.ws.rs.GET;
    import jakarta.ws.rs.Path;
    import jakarta.ws.rs.Produces;
    import jakarta.ws.rs.core.MediaType;
    
    @Path("/hello")
    public class GreetingResource {
    
        @GET
        @Produces(MediaType.TEXT_PLAIN)
        public String hello() {
            return "Hello from Quarkus REST";
        }
    }

     

    This file contains a simple REST endpoint that returns Hello from Quarkus REST as a response to a request that you send to the /hello endpoint.

Verification
  • Run the application in a command terminal.

    quarkus dev

     

    1. In a new terminal, call the endpoint:

      curl -w "\n" http://localhost:8080/hello

      The response is:

      Hello from Quarkus REST

       

  • Make a live code change to confirm the dev-mode feedback loop. For example, change the returned string to something else (for example, "Hello, world!") and save the file. Then re-run the curl command.