The idea is to build a toy blog site running on Java using native images. This started as an experiment but seemed good enough to be shared with other good folks of open source world.
Steps
Download and install postgres, else use docker-compose file from within the repository to set up.
You can grab the latest version from Github Packages.
Download the executable runner file (JAR), current version has the name cube-blog-1.0.1-runner.jar
Use below command to override the local defaults
java -Dquarkus.datasource.password=no-one-knows \
-Dquarkus.datasource.username=probably-few-know \
-Dquarkus.datasource.jdbc.url=jdbc:postgresql://my-blog-host:5432/my-awesome-db \
-Djwt.secret=My-Super-Secret-String \
-jar cube-blog-1.0.1-runner.jar \
This project uses Quarkus.
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
You can run your application in dev mode that enables live coding using:
./mvnw quarkus:dev
The application can be packaged using ./mvnw package
.
It produces the cube-blog-1.0.0-SNAPSHOT-runner.jar
file in the /target
directory.
The jar produced is an uber-jar
, and this can be changed by updating property in application.properties
file.
The application is now runnable using java -jar target/cube-blog-1.0.0-SNAPSHOT-runner.jar
.
You can create a native executable using: ./mvnw package -Pnative
. This step requires GraalVM, the project uses Java 11 specific JDK.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: ./mvnw package -Pnative -Dquarkus.native.container-build=true
.
You can then execute your native executable with: ./target/cube-blog-1.0.0-SNAPSHOT-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image.