Create Quarkus applications

Red Hat build of Quarkus 3.33

Red Hat Customer Content Services

Abstract

This guide describes how to create Quarkus applications.

Chapter 1. Create a Getting started project

The getting-started project is a simple Quarkus application that you can build to explore the framework and validate your development environment.

To create a getting-started project, use one of the following methods:

  • Follow the tutorial in the "Build your first application" guide, which uses Apache Maven and the Quarkus Maven plugin.
  • Generate a Quarkus Maven project from code.quarkus.redhat.com.
  • Use the Quarkus command-line interface (CLI).
Important

The Content from quarkus.io is not included.Quarkus CLI is intended for development purposes, including tasks such as creating, updating, and building Quarkus projects. However, Red Hat does not support using the Quarkus CLI in production environments.

Additional resources

Chapter 2. Create the Getting started project by using code.quarkus.redhat.com

You can use the This content is not included.code.quarkus.redhat.com application to generate a Quarkus Maven project and automatically add and configure the extensions that you want to use in your application. In addition, This content is not included.code.quarkus.redhat.com automatically manages the configuration parameters that are required to compile your project into a native executable.

You can generate a Quarkus Maven project, including the following activities:

  • Specifying basic details about your application
  • Choosing the extensions that you want to include in your project
  • Generating a downloadable archive with your project files
  • Using custom commands for compiling and starting your application

Prerequisites

Procedure

  1. On your web browser, go to This content is not included.https://code.quarkus.redhat.com.
  2. From the list of available versions, the code.quarkus.redhat.com application selects the latest release of Red Hat build of Quarkus by default.

    Note

    code.quarkus.redhat.com uses the latest release of Red Hat build of Quarkus, which is the preferred option. However, after generating your project, you can manually change to an earlier BOM version in the pom.xml file if necessary, but the best practice is to keep the default.

  3. Specify basic details about your project:

    Screenshot of the basic application details section on the code.quarkus.redhat.com site
    1. Enter a group name for your project. The name format follows the Java package naming convention; for example, org.acme.
    2. Enter a name for the Maven artifacts generated by your project, such as code-with-quarkus.
    3. Select the build tool you want to use to compile and start your application. The build tool that you choose determines the following setups:

      • The directory structure of your generated project
      • The format of configuration files that are used in your generated project
      • The custom build script and command for compiling and starting your application that code.quarkus.redhat.com displays for you after you generate your project

        Note

        Red Hat provides support for using code.quarkus.redhat.com to create Quarkus Maven projects only.

  4. Specify additional details about your application project:

    1. To display the fields that contain further application details, select More options.

      Screenshot of the application details section on the code.quarkus.redhat.com site showing the extended form with additional application details
    2. Enter a version you want to use for artifacts generated by your project. The default value of this field is 1.0.0-SNAPSHOT. Using Content from semver.org is not included.semantic versioning is preferred; however, you can choose to specify a different versioning type.
    3. Select whether you want code.quarkus.redhat.com to add starter code to your project. When you add extensions that are marked with "STARTER-CODE" to your project, you can enable this option to automatically create example class and resource files for those extensions when you generate your project. However, this option does not affect your generated project if you do not add any extensions that provide example code.
  5. Select the extensions that you want to use. The Quarkus application includes the extensions you select as dependencies. The Quarkus platform also ensures these extensions are compatible with future versions.

    Important

    Do not use the quarkus-rest and the quarkus-resteasy extensions in the same project. Both provide similar capabilities, but they differ significantly in implementation and behavior. Use quarkus-rest instead.

    The quark icon ( Quark icon ) next to an extension indicates that the extension is part of the Red Hat build of Quarkus platform release. Red Hat prefers using extensions from the same platform because they are tested and verified together, making them easier to use and upgrade.

    For extensions marked with "STARTER-CODE", you can enable the option to generate starter code automatically.

    Screenshot of the list of extensions at the code.quarkus.redhat.com site that you can add to your project

  6. To confirm your choices, select Generate your application. After generation, a dialog box displays the following items:

    • A link to download the archive that contains your generated project
    • A command that you can use to compile and start your application
  7. To save the archive with the generated project files to your machine, select Download the ZIP.
  8. Extract the contents of the archive.

Verification

  1. Check the extracted structure and verify the pom.xml file is present in the root directory of your generated project.
  2. Start the application in dev mode. Use either Apache Maven or the Maven wrapper:

    mvn quarkus:dev

     

    or

    ./mvnw quarkus:dev

     

    The following extract shows an example of the expected output:

    INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
    INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, rest, smallrye-context-propagation, vertx]

Chapter 3. Create the Getting started project by using the quarkus CLI

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 Content from quarkus.io is not included.Quarkus CLI is intended for development purposes, including tasks such as creating, updating, and building Quarkus projects. However, Red Hat 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.

Chapter 4. Reconfigure your Maven project from community Quarkus to Red Hat build of Quarkus

You can migrate a Quarkus community project to Red Hat build of Quarkus by changing the Maven configuration in your project POM file.

Prerequisites

Procedure

  • Change the following values in the <properties> section of the pom.xml file of your project:

    • Change the value of the <quarkus.platform.group-id> property to com.redhat.quarkus.platform.
    • Change the value of the <quarkus.platform.version> property to 3.33.1.redhat-00006.

      pom.xml

      <project>
        ...
        <properties>
           ...
           <quarkus.platform.group-id>com.redhat.quarkus.platform</quarkus.platform.group-id>
           <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
           <quarkus.platform.version>3.33.1.redhat-00006</quarkus.platform.version>
           ...
        </properties>
        ...
      </project>

Chapter 5. Support levels for Red Hat build of Quarkus extensions

Red Hat provides different levels of support for extensions that are available on code.quarkus.redhat.com that you can add to your Quarkus project. Labels next to the name of each extension indicate the support level.

Important

Red Hat does not support unlabeled extensions for use in production environments.

Screenshot of an expanded overflow menu next to one of the extensions on code.quarkus.redhat.com showing the custom commands that you can copy

Red Hat provides the following levels of support for Red Hat build of Quarkus extensions:

Table 5.1. Support levels provided by Red Hat for Red Hat build of Quarkus extensions

Support levelDescription

SUPPORTED

Red Hat fully supports extensions for use in enterprise applications in production environments.

TECH-PREVIEW

Red Hat offers limited support to extensions in production environments under the Technology Preview scope of support scope of support.

DEPRECATED

Red Hat plans to replace extensions with more recent technology or implementation that provides the same functionality.

DEV-SUPPORT

Red Hat does not support extensions for use in production environments, but Red Hat developers support the core functionality that they provide for use in developing new applications.

SUPPORTED-IN-JVM

Red Hat supports extensions that are tested and verified for use in Java Virtual Machine (JVM) environments.

DEV-PREVIEW

Red Hat does not support extensions for use in production environments. They are provided only as a Developer Preview as defined by the This content is not included.Developer preview - scope of support.

EXPERIMENTAL

Red Hat does not support extensions for use in production environments. Early feedback is requested to further mature the extension proposal. No guarantee of stability or long term inclusion on the platform.

PREVIEW

Red Hat does not support extensions for use in production environments. Extensions are available in the Quarkus community version only.

By clicking the arrow icon (⌄) beside each of the extensions, you can expand the overflow menu to access further actions for that extension. For example:

  • Add the extension to an existing project by using the Quarkus Maven plugin on the command line
  • Copy an XML snippet to add the extension to a project’s pom.xml file
  • Obtain the groupId, artifactId, and version of each extension
  • Open the extension guide

Legal Notice

Copyright © Red Hat.
Except as otherwise noted below, the text of and illustrations in this documentation are licensed by Red Hat under the Creative Commons Attribution–Share Alike 3.0 Unported license . If you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, the Red Hat logo, JBoss, Hibernate, and RHCE are trademarks or registered trademarks of Red Hat, LLC. or its subsidiaries in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS is a trademark or registered trademark of Hewlett Packard Enterprise Development LP or its subsidiaries in the United States and other countries.
The OpenStack® Word Mark and OpenStack logo are trademarks or registered trademarks of the Linux Foundation, used under license.
All other trademarks are the property of their respective owners.