{{announcement.body}}
{{announcement.title}}
refcard cover
Refcard #319

Getting Started With Quarkus

In this Refcard, an expert developer walks through the Quarkus platform, an open source Kubernetes-native Java stack that enables smaller, faster Java programs. Learn how to improve the developer experience through features like live reloading, debugging, and more. Its integration with the Eclipse MicroProfile specification also makes it the perfect choice for developing microservices and deploying them in Kubernetes.

Free PDF for Easy Reference
refcard cover

Written By

author avatar Alex Soto
Software Engineer, Red Hat
Section 1

Key Benefits

Quarkus offers near-instant scale-up and high-density utilization in container orchestration platforms such as Kubernetes. Many more application instances can be run using the same hardware resources. In Quarkus, classes used only at application startup are invoked at build time and not loaded into the runtime JVM. 

Quarkus also avoids reflection as much as possible. These design principles reduce the size and the memory footprint of an application running on the JVM. Quarkus’ design accounts for native compilation from the onset; optimization for using GraalVM, specifically its native image capability, to compile JVM bytecode to a native machine binary.

Additionally, Quarkus rests on a vast ecosystem of technologies, standards, libraries, and APIs. Developers don’t have to spend lots of time learning an entirely new set of APIs and technologies to take advantage of the benefits Quarkus brings to the JVM or native images.


This is a preview of the Getting Started With Quarkus Refcard. To read the entire Refcard, please download the PDF from the link above.

Section 2

Getting Started

To create a Quarkus service, you just need to run the next Maven goal into an empty directory: 

Java
 




xxxxxxxxxx
1


 
1
mvn io.quarkus:quarkus-maven-plugin:1.13.1.Final:create \
2
-DprojectGroupId=org.acme \
3
-DprojectArtifactId=hello-world \
4
-DclassName="org.acme.quickstart.GreetingResource" \
5
-Dpath="/hello"



Live Reload 

Quarkus applications come with a live reload feature that allows the developer to make changes to their source code, which will be directly reflected in the deployed code without having to recompile or repackage the source code.

Java
 




xxxxxxxxxx
1


 
1
./mvnw compile quarkus:dev



This service is started locally and you can use a curl command on the http://localhost:8080/hello URL to get a response from the service.


This is a preview of the Getting Started With Quarkus Refcard. To read the entire Refcard, please download the PDF from the link above.

Section 3

Key Components

JAX-RS 

Quarkus uses the JAX-RS spec for implementing RESTful web services, as shown below:

Java
 




xxxxxxxxxx
1
41


1
@Path("/developer")
2
public class DeveloperResource {
3
 
4
    @GET
5
     @Produces(MediaType.APPLICATION_JSON)
6
    public List<Developer> getAllDevelopers() {}
7
 
8
    @POST
9
     @Produces(MediaType.APPLICATION_JSON)
10
    public Response createDeveloper(Developer developer) {}
11
 
12
    @DELETE
13
    @Path("{id}")
14
     @Produces(MediaType.APPLICATION_JSON)
15
    public Response deleteDeveloper(@PathParam("id") Long id) {}
16
 
17
    @GET
18
     @Produces(MediaType.APPLICATION_JSON)
19
     @Path("search")
20
    public Response searchDeveloper(@QueryParam("skills") String skills) {}
16
 
21
}


 

JSON Marshalling and Unmarshalling 

To marshal and unmarshal Java objects to JSON format, you need to register either the JSON-B or Jackson extension: 

Java
 




xxxxxxxxxx
1


 
1
./mvnw quarkus:add-extension -Dextensions="resteasy-jsonb"



Or:

Java
 




xxxxxxxxxx
1


 
1
./mvnw quarkus:add-extension -Dextensions="resteasy-jackson"




This is a preview of the Getting Started With Quarkus Refcard. To read the entire Refcard, please download the PDF from the link above.

Section 4

Conclusion

Java has evolved since its introduction in 1995, but more importantly, the environments hosting applications have evolved as well. Some trade-offs made in Java’s design at the onset affect how Java is perceived today. Things that were important in those days aren’t as important anymore. Quarkus was invented given the challenges and problems of today and aims to solve those challenges without forcing developers to learn an entirely new programming language.

This Refcard has shown how to use some of the most common extensions within the Quarkus ecosystem. Please visit https://code.quarkus.io for a list of all extensions as well as https://quarkus.io/guides/ for further information on building Quarkus applications.


This is a preview of the Getting Started With Quarkus Refcard. To read the entire Refcard, please download the PDF from the link above.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}