Day 1: Setup Java sdk, maven and init Quarkus app
Actually, this is not the first day of setup java SDK and init app with quarkus. I tried 1, 2 times before but failed. A lot bugs raised: conflict btw version of openSdk what I am using and what Maven used, …
Finally, after 2 hours dive into research and trying, I successful initiated an Quarkust app by maven.
These are steps that I do:
step 1: Install java 21
download zip file of java-21-openjdk-amd64
unzap this file and move to opt
set default java jdk that system will use
sudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
Set java_home
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
then check byecho $JAVA_HOME
Step 2: install maven
install maven latest from maven website
- download tar file
- unzip
- move to optmv apache-maven-3.6.3 /opt/
Set maven_home
(if use fish) update file `.profile`
- nano .profile
- copy paste this content:
set M2_HOME '/opt/apache-maven-3.6.3'
PATH "$M2_HOME/bin:$PATH"
export PATHCheck maven version (mvn -v) to ensure that mvn is using java 21.
Step 3: Init app
create app folder
go to inside folder
open terminal and run script
mvn io.quarkus.platform:quarkus-maven-plugin:3.14.4:create \ -DprojectGroupId=my-groupId \
-DprojectArtifactId=apiNow you have a project tree like below:
yeah yeah
Layout code with OOP
muno/ <-- Project root ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── muno/ │ │ │ ├── order/ │ │ │ │ ├── OrderResource.java <-- Order API logic │ │ │ │ ├── OrderService.java <-- Order business logic │ │ │ │ └── OrderRepository.java <-- Order data access │ │ │ ├── product/ │ │ │ │ ├── ProductResource.java <-- Product API logic │ │ │ │ ├── ProductService.java <-- Product business logic │ │ │ │ └── ProductRepository.java <-- Product data access │ │ │ ├── auth/ │ │ │ │ ├── AuthResource.java <-- Authentication API logic │ │ │ │ ├── AuthService.java <-- Authentication business logic │ │ │ │ └── AuthRepository.java <-- Authentication data access │ │ │ └── MunoApplication.java <-- Main application entry point │ │ └── resources/ │ │ ├── application.properties <-- Configuration file │ │ ├── META-INF/ │ │ │ └── resources/ <-- Static resources (HTML, CSS, etc.) │ │ └── templates/ <-- Template files (e.g., Thymeleaf) │ └── test/ │ ├── java/ │ │ └── com/ │ │ └── muno/ │ │ ├── order/ │ │ │ └── OrderResourceTest.java <-- Order tests │ │ ├── product/ │ │ │ └── ProductResourceTest.java <-- Product tests │ │ └── auth/ │ │ └── AuthResourceTest.java <-- Authentication tests │ └── resources/ │ └── test-data/ <-- Test-specific resources ├── pom.xml <-- Maven build configuration └── target/ <-- Compiled output (created after building)
Subscribe to my newsletter
Read articles from johnd directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by