Creating UberJARs / FatJARs with Quarkus

Quarkus usually ships as a "SkimmedJAR" with cleanly separated business logic and infrastructure.

Setting the quarkus.package.uber-jar parameter to true in application.properties, creates a self contained, executable JAR in the target folder.

The simplest possible "hello,world" UberJAR with cdi and resteasy extensions takes ~9MB disk space.

Although it is hard to find any good arguments (do you know any?) to use this approach for container, kubernetes or clouds deployments, Quarkus UeberJARs are perfect for building electron-like desktop apps.

Big thanks to Alex Soto @alexsotob for the hint.


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Jar Inspection Utility (xplr) v0.0.2 was released

After four years, Jar Explorer (xplr) v0.0.2 "Singleton" was released.

Now individual JARs (v0.0.1 scanned entire directories) can be inspected, e.g

java -jar xplr.jar maven-core-3.6.3.jar generates the following output:


#####################################
Directory: .
#####################################

# Jar: ./maven-core-3.6.3.jar
## Manifest:
## Package: org.apache.maven.lifecycle.internal.builder.singlethreaded
Implementation-Title:Maven Core
Implementation-Version:3.6.3
Specification-Vendor:The Apache Software Foundation
Specification-Title:Maven Core
Build-Jdk-Spec:1.8
Created-By:Maven Jar Plugin 3.2.0
Specification-Version:3.6
Manifest-Version:1.0
Implementation-Vendor:The Apache Software Foundation

## POM:

org.apache.maven
maven-core
3.6.3

## MVN install command:
mvn install:install-file -Dfile=./maven-core-3.6.3.jar -DgroupId=org.apache.maven -DartifactId=maven-core -Dversion=3.6.3 -Dpackaging=jar
---


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

KISS and No Dependencies in JGroups--airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #72 airhacks.fm episode with Bela Ban about:
Bela Ban about JGroups, Distributed Programming, ignoring hypes, Loom, Fibers, KISS and the advantages of "No Dependencies"
is available for download.


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Using MicroProfile Config to Render Web Components on the Server with JSP

To inject dynamic content to *.js files on the server side, the JSP's (Jakarta Server Pages) file extension has to be configured in web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app>
    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.js</url-pattern>
            <page-encoding>UTF-8</page-encoding>
            <default-content-type>text/javascript</default-content-type>
        </jsp-property-group>
    </jsp-config>
</web-app>

Now a String array exposed from a CDI bean:


import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@Named
@ApplicationScoped
public class Developer {

    @Inject
    @ConfigProperty(name = "languages")
    String languages;

    public String getLanguages() {
        return languages;
    }
}

...and configured in microprofile-config.properties:


languages=jsp,javascript,java    

...can be directly used to generate e.g. Web Components / Custom Elements:


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

class Languages extends HTMLElement{

        connectedCallback() {
        this.innerHTML = `
            <select>
                <c:forEach items="${developer.languages}" var="language">
                    <option>${language}</option>
                </c:forEach>
            </select>`;

    }
}
customElements.define('a-languages',Languages);    

See it in action and from scratch:

The 4kB ThinWAR project was created with Jakarta EE Essentials Archetype and deployed with: wad.sh in 2.4s


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Productivity with Plain Vanilla Web Components--airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #71 airhacks.fm episode with Robert Brem (@bremrobert) about:
"replacing dependencies and frameworks with web standards and Web Components to increase productivity"
is available for download.


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Injecting List of Strings with MicroProfile Config

A comma-separated String in microprofile-config.properties:


messages=hello,bye

...can be injected as a List of Strings (other types are injectable as well):

import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@Path("messages")
public class MessagesResource {

    @Inject
    @ConfigProperty(name = "messages")
    List<String> messages;    

    @GET
    public List<String> messages() {
        return this.messages;
    }
}

The following command: curl -i localhost:8080/[THIN_WAR_NAME]/resources/messages prints: ["hello","bye"]

The 4kB ThinWAR project was created with Jakarta EE Essentials Archetype and deployed with: wad.sh in 1.9s


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Using Jakarta Server Pages (JSP)s For Web Component Generation / Configuration

JavaScript can be pre-generated on the backend and delivered as static content with JSPs. Jakarta Server Pages (JSP) are used in this screencast to configure a stage-dependent URI in a Web Component / Custom Element defined with MicroProfile Config and exposed via CDI:

The ThinWAR project was created with Jakarta EE Essentials Archetype, the 216kB ThinWAR (JS dependencies included) was built and deployed to Payara 5.193 #badassfish with: wad.sh in 3.2s


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Memory Consumption: WildFly Full ThinWAR vs. Quarkus SkimmedJAR

Comparing the memory consumption of WildFly 18.0.1.Final (Java EE Full & Web Distribution) and Quarkus by deploying identical microprofile application to both runtimes:

The ThinWAR project was created with Jakarta EE Essentials Archetype, the 6kB ThinWAR was built and deployed with: wad.sh in 3.1s.

The Quarkus Runner 20.3kB "SkimmedJAR" was built in 4.3s from scratch. The file size of the native executable was 32 MB, the built took 53.7s.


NEW airhacks.com workshops: MicroProfile with Quarkus and Micro Frontends with Web Components at MUC airport

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License