Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Build your first Java serverless function using a Quarkus quick start

March 28, 2022
Daniel Oh
Related topics:
JavaQuarkusServerless
Related products:
Developer SandboxRed Hat OpenShift ServerlessRed Hat OpenShift

    Are you looking for the shortest path or cheatsheet to bring your Java application into a serverless platform based on Kubernetes? Perhaps you don't have enough time to stand up relevant infrastructure and configure settings for both the application and the platform. This article is a guide to developing Java serverless functions using a Quarkus quick start in the Developer Sandbox for Red Hat OpenShift. As you'll see, using quick starts in the Developer Sandbox lets you focus on the application development without needing to configure Knative.

    The Developer Sandbox provides a shared, multi-tenant Red Hat OpenShift 4 cluster with a cloud IDE tool called Red Hat CodeReady Workspaces. All you need is a free account on Red Hat to get access for a limited time to a sandbox. Following the four steps in this article, you can stand up your own cluster in 10 minutes.

    Step 1. Launch your sandbox

    Go to the Welcome page for Developer Sandbox, then click the red Launch button shown in Figure 1. Log in using your Red Hat account.

    You can launch a sandbox from the Welcome page.
    Figure 1. You can launch a sandbox from the Welcome page.
    Figure 1: You can launch a sandbox from the Welcome page.

    Step 2. Choose the Quarkus serverless functions quick start

    Once you are logged in to the sandbox, go to the +Add view in the Developer perspective. Click View all quick starts, then type serverless into the search box. Choose the Get started with Quarkus serverless functions quick start, as shown in Figure 2.

    The Developer Sandbox offers many quick starts.
    Figure 2. The Developer Sandbox offers many quick starts.
    Figure 2: The Developer Sandbox offers many quick starts.

    Step 3. Start the development of your serverless functions using Quarkus

    This 10-minute quick start develops some serverless functions in CodeReady Workspaces and deploys the functions to OpenShift using Quarkus extensions. The quick start takes you through the following tasks:

    1. Launch CodeReady Workspaces
    2. Run the Live Coding to develop new serverless functions
    3. Test your first serverless function
    4. Add a new serverless function using Quarkus CDI
    5. Deploy the Quarkus serverless function to OpenShift
    6. Access the functions on OpenShift

    The quick start guides you through the step-by-step instructions to complete the tasks. When you complete each task, click Next to verify your work. If you have accomplished the task without any issues, click Yes and then Next to move forward to the next task, as shown in Figure 3.

    Click Yes to check your work.
    Figure 3. Click Yes to check your work.
    Figure 3: Click Yes to check your work.

    Most tasks in this quick start are self-explanatory, but a couple of them are worth exploring.

    Task 3: Add a new serverless function using Quarkus CDI

    Quarkus simplifies bean discovery using the @Inject annotation, which is based on the Contexts and Dependency Injection (CDI) specification. You can also use this bean discovery while you're developing serverless functions, as in the following code:

    @Inject
    MyFunctionsService myFunctionsService;
    
    @Funq
    public String greeting(String name) {
    
        return myFunctionsService.greeting(name);
    
    }

    When you check your work using the curl command-line tool, you don't even need to save the source file, recompile, and restart the application after changing the code. Quarkus development mode updates the running application through Live Coding, as shown in Figure 4. The conveniences of this learning environment let you focus on serverless functions development.

    Use a curl command to check the status of your application.
    Figure 4. Use a curl command to check the status of your application.
    Figure 4: Use a curl command to check the status of your application.

    Task 5: Deploy the Quarkus serverless function to OpenShift

    This quick start uses the Quarkus Funqy extension to make your serverless function (greeting) portable across multiple serverless platforms, including Red Hat OpenShift Serverless, AWS Lambda, Azure Functions, Google Cloud Platform, and Knative.

    All required configurations are set in the application.properties file except the quarkus.container-image.group value. You need to replace USERNAME with your account (e.g., doh). Then deploy the Quarkus application using the Maven command-line tool. In the end, the Topology view displays the pod with a function icon, as shown in Figure 5.

    Deploy the Quarkus serverless function to OpenShift
    Figure 5: Deploy the Quarkus serverless function to OpenShift
    Figure 5: Deploy the Quarkus serverless function to OpenShift.

    The function pod might scale down to zero if there's no incoming traffic to the pod for 30 seconds.

    When you have completed all six tasks, you will see the green checkmarks shown in Figure 6.

    The green checkmarks indicate that all tasks have been completed.
    Figure 6: The green checkmarks indicate that all tasks have been completed.
    Figure 6: The green checkmarks indicate that all tasks have been completed.

    Conclusion

    In this article, you've learned how quickly you can get started with the development and deployment of Java serverless functions using a Quarkus quick start in the Developer Sandbox for Red Hat OpenShift. The sandbox also provides an out-of-the-box IDE environment for those developers who want to begin cloud-native microservices development on day 1. Visit the Developing with Quarkus self-service learning portal to learn more about Java application development using Quarkus.

    Last updated: October 31, 2023

    Recent Posts

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.