Quarkus is a Kubernetes Native Java framework tailored for OpenJDK HotSpot and GraalVM devloped by Redhat.
For more information on Quarkus please go through the below link https://quarkus.io/
Quarkus plugins are available for almost all the IDEs, Since Eclipse is widely used IDE platform for java based application, Lets add Quarkus plugin to Eclipse
Make Sure to install JDK 11 before starting the Quarkus setup process
Download the latest Eclipse from the below URL https://www.eclipse.org/downloads/packages/
Note: Download the below package
Extract the downloaded Zip eclipse-java-2021-06-R-win32-x86_64.zip
After successful extraction of the files, go inside the eclipse directory and update the memory configurations in eclipse.ini file
Default configuration which is set is below
-Xms256m
-Xmx2048m
Update the minimum and max memory to
-Xms1024m
-Xmx4096m
Reason for updating the the min and max memory is Quarkus tools internally installs loads of features and dependencies through equniox osgi runtime, these new features and plugins uses heap space resources , If the heap space configuration is low eclipse will not open and throws a error pop up with message max heap space error.
Open eclipse (eclipse.exe will start eclipse)
Create a workspace (name of the workspace can be of your choice) and click on launch button
3. After Eclipse is started, click on the Help menu and click on Eclipse Marketplace.
Clicking on the Eclipse Marketplace from help menu, Eclipse Marketplace applet pops ups which helps us to search for the plugins and install as part of your eclipse IDE.
In the Find (search bar), Type Quarkus and press enter
Now in the search results you will in the Quarkus tools plugin available for install, Now click on install button to integrate Quarkus to your eclipse IDE.
Select all the packages and click on confirm.
Accept the license and click on finish button.
While installing any new plugin to eclipse, eclipse gives a security warning pop up, no need to worry its a default security message from eclipse while integrating any new plugin, click on Install anyway.
Once the plugin in installed to the eclipse equinox osgi runtime, we get a message pop to restart the eclipse IDE
click on restart now button, this will restart eclipse (internally equinox runtime will be refreshed with new changes). Once the eclipse is started, We are now ready to create Quarkus projects.
To create a Quarkus Project.
Click on File menu, then navigate to New and click on Other section.
Under Wizard Pop up type Quarkus, and select Quarkus project and press Next button
Under project type select maven and provide the a name to the project and click on next button
provide your artifact id, group id, Version, Package for your restful webservice class and path where the service to be exposed and finally click on finish button.
Eclipse will now creates a Quaker project which is also docker ready.
update the class AddTwoNumberClass as per the below code snippet to accept path params through request URL.
package org.brktech.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/addition/{a}+{b}")
public class AddTwoNumberClass {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello(@PathParam("a") int a, @PathParam("b") int b) {
return "Addition of Numbers " + a + " and " + b + " is " + (a + b);
}
}
Eclipse Compile and Deployment
Now lets compile and deploy through maven build, Right click on the project and navigate through Run as and select Maven Build
add "compile quarkas:dev" under Goals and press run
Rest application will be deployed in Quarkus Runtime (Also called as serverless runtime) and we can access the deployed rest service through the default port 8080
Maven Command Line Package and Deployment
Go through the project location in CMD promt (windows, you can use the same procedure via terminal in Linux), execute the command "mvn clean package -DskipTests"
now go to target/quarkus-app/ folder and execute the command below
"java -jar quarkus-run.jar"
Accessing the Rest Service
By default Quarkus exposes the service through the port 8080,
Now lets hit the rest service url by passing two numbers through a browser as below
localhost:8080/addition/number1+number2
Response we get is as below
EmoticonEmoticon