{"id":25558993,"url":"https://github.com/vertx-howtos/jlink-howto","last_synced_at":"2026-05-05T03:39:32.544Z","repository":{"id":275621437,"uuid":"926598403","full_name":"vertx-howtos/jlink-howto","owner":"vertx-howtos","description":"Assembling a small runtime image  of a modular Vert.x application with jlink","archived":false,"fork":false,"pushed_at":"2025-02-04T10:28:39.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-04-06T16:41:49.449Z","etag":null,"topics":["howto","jlink","jpms","vertx"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vertx-howtos.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-03T14:42:26.000Z","updated_at":"2025-02-04T10:28:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc684e36-5fb3-4cbf-ba37-b6c342e156f6","html_url":"https://github.com/vertx-howtos/jlink-howto","commit_stats":null,"previous_names":["vertx-howtos/jlink-howto"],"tags_count":0,"template":false,"template_full_name":"vertx-howtos/howto-template","purl":"pkg:github/vertx-howtos/jlink-howto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertx-howtos%2Fjlink-howto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertx-howtos%2Fjlink-howto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertx-howtos%2Fjlink-howto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertx-howtos%2Fjlink-howto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vertx-howtos","download_url":"https://codeload.github.com/vertx-howtos/jlink-howto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertx-howtos%2Fjlink-howto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32634727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["howto","jlink","jpms","vertx"],"created_at":"2025-02-20T16:26:32.480Z","updated_at":"2026-05-05T03:39:32.539Z","avatar_url":"https://github.com/vertx-howtos.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Assembling a small runtime image of a modular Vert.x application with jlink\n:page-permalink: /\n:page-github: vertx-howtos/jlink-howto\n\nifdef::env-github[]\nimage:https://github.com/vertx-howtos/jlink-howto/workflows/Publish%20the%20how-to/badge.svg[\"Build Status\",link=\"https://github.com/vertx-howtos/jlink-howto/actions?query=workflow%3A%22Publish+the+how-to%22\"]\nendif::env-github[]\n\nThis document will show you how to assemble a small runtime image of a modular Vert.x application with jlink.\n\n== What you need\n\n* A text editor or an IDE\n* Java 11 or higher\n\n== Create a project\n\nHere is the content of the Maven `pom.xml` file you should be using:\n\nifdef::env-github[]\nlink:pom.xml[Maven POM file]\nendif::env-github[]\nifndef::env-github[]\n[source,xml]\n.Maven `pom.xml`\n----\ninclude::pom.xml[]\n----\n\n\u003c1\u003e The https://maven.apache.org/plugins/maven-jlink-plugin/[Apache Maven JLink Plugin] will take care of invoking the `jlink` command-line tool.\n\u003c2\u003e Mandatory classifier for the custom runtime image archive that will be attached as a Maven artifact.\n\u003c3\u003e `server` is the name of the launcher script to generate via jlink.\nThis is optional.\n\u003c4\u003e Add the `jdk.jdwp.agent` module so that we can attach a remote debugger, if we need to.\nendif::env-github[]\n\n== Implementing the application\n\nThe server setup code fits into a single class, `io.vertx.howtos.jlink.ServerVerticle`:\n\nifdef::env-github[]\nlink:src/main/java/io/vertx/howtos/jlink/ServerVerticle.java[ServerVerticle.java]\nendif::env-github[]\nifndef::env-github[]\n[source,java]\n----\ninclude::src/main/java/io/vertx/howtos/jlink/ServerVerticle.java[]\n----\nendif::env-github[]\n\nA custom application launcher provides a factory for the main verticle to deploy:\n\nifdef::env-github[]\nlink:src/main/java/io/vertx/howtos/jlink/CustomLauncher.java[CustomLauncher.java]\nendif::env-github[]\nifndef::env-github[]\n[source,java]\n----\ninclude::src/main/java/io/vertx/howtos/jlink/CustomLauncher.java[]\n----\nendif::env-github[]\n\nHaving the verticle factory in `io.vertx.howtos.jlink.CustomLauncher` simplifies the Java module configuration:\n\nifdef::env-github[]\nlink:src/main/java/module-info.java[module-info.java]\nendif::env-github[]\nifndef::env-github[]\n[source,java]\n----\ninclude::src/main/java/module-info.java[]\n----\nendif::env-github[]\n\nIndeed, since the verticle instance won't be created via reflection, we don't have to export our application package to the `io.vertx.core` module, we just have to declare a few required modules.\n\n== Building the application\n\nOn Linux or other Unix-like systems, run the following command:\n\n[source,bash]\n----\n./mvnw clean package\n----\n\nOn Microsoft Windows:\n\n[source,shell]\n----\nmvnw.cmd clean package\n----\n\nNotice that all required modules are resolved before `jlink` creates the custom runtime image.\n\n----\n[INFO] --- jlink:3.2.0:jlink (jlink) @ jlink-howto ---\n[INFO]  -\u003e module: io.netty.handler ( /path/to/my/mavenrepo/io/netty/netty-handler/4.2.0.RC1/netty-handler-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.vertx.web ( /path/to/my/mavenrepo/io/vertx/vertx-web/5.0.0.CR4/vertx-web-5.0.0.CR4.jar )\n[INFO]  -\u003e module: io.vertx.core ( /path/to/my/mavenrepo/io/vertx/vertx-core/5.0.0.CR4/vertx-core-5.0.0.CR4.jar )\n[INFO]  -\u003e module: io.netty.handler.proxy ( /path/to/my/mavenrepo/io/netty/netty-handler-proxy/4.2.0.RC1/netty-handler-proxy-4.2.0.RC1.jar )\n[INFO]  -\u003e module: com.fasterxml.jackson.core ( /path/to/my/mavenrepo/com/fasterxml/jackson/core/jackson-core/2.16.1/jackson-core-2.16.1.jar )\n[INFO]  -\u003e module: io.netty.codec.unused ( /path/to/my/mavenrepo/io/netty/netty-codec/4.2.0.RC1/netty-codec-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.vertx.launcher.application ( /path/to/my/mavenrepo/io/vertx/vertx-launcher-application/5.0.0.CR4/vertx-launcher-application-5.0.0.CR4.jar )\n[INFO]  -\u003e module: io.vertx.auth.common ( /path/to/my/mavenrepo/io/vertx/vertx-auth-common/5.0.0.CR4/vertx-auth-common-5.0.0.CR4.jar )\n[INFO]  -\u003e module: info.picocli ( /path/to/my/mavenrepo/info/picocli/picocli/4.7.4/picocli-4.7.4.jar )\n[INFO]  -\u003e module: io.vertx.howtos.jlink ( /path/to/my/Projects/vertx-howtos/jlink-howto/target/classes )\n[INFO]  -\u003e module: io.netty.transport.unix.common ( /path/to/my/mavenrepo/io/netty/netty-transport-native-unix-common/4.2.0.RC1/netty-transport-native-unix-common-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec.compression ( /path/to/my/mavenrepo/io/netty/netty-codec-compression/4.2.0.RC1/netty-codec-compression-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.vertx.web.common ( /path/to/my/mavenrepo/io/vertx/vertx-web-common/5.0.0.CR4/vertx-web-common-5.0.0.CR4.jar )\n[INFO]  -\u003e module: io.netty.buffer ( /path/to/my/mavenrepo/io/netty/netty-buffer/4.2.0.RC1/netty-buffer-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec.http2 ( /path/to/my/mavenrepo/io/netty/netty-codec-http2/4.2.0.RC1/netty-codec-http2-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.vertx.core.logging ( /path/to/my/mavenrepo/io/vertx/vertx-core-logging/5.0.0.CR4/vertx-core-logging-5.0.0.CR4.jar )\n[INFO]  -\u003e module: io.netty.common ( /path/to/my/mavenrepo/io/netty/netty-common/4.2.0.RC1/netty-common-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.resolver.dns ( /path/to/my/mavenrepo/io/netty/netty-resolver-dns/4.2.0.RC1/netty-resolver-dns-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec.http ( /path/to/my/mavenrepo/io/netty/netty-codec-http/4.2.0.RC1/netty-codec-http-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec.socks ( /path/to/my/mavenrepo/io/netty/netty-codec-socks/4.2.0.RC1/netty-codec-socks-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec.dns ( /path/to/my/mavenrepo/io/netty/netty-codec-dns/4.2.0.RC1/netty-codec-dns-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.transport ( /path/to/my/mavenrepo/io/netty/netty-transport/4.2.0.RC1/netty-transport-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.codec ( /path/to/my/mavenrepo/io/netty/netty-codec-base/4.2.0.RC1/netty-codec-base-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.netty.resolver ( /path/to/my/mavenrepo/io/netty/netty-resolver/4.2.0.RC1/netty-resolver-4.2.0.RC1.jar )\n[INFO]  -\u003e module: io.vertx.eventbusbridge ( /path/to/my/mavenrepo/io/vertx/vertx-bridge-common/5.0.0.CR4/vertx-bridge-common-5.0.0.CR4.jar )\n[INFO] Building zip: /path/to/my/vertx-howtos/jlink-howto/target/jlink-howto-dist.zip\n----\n\n== Running the application\n\nExtract the `target/jlink-howto-dist.zip` archive somewhere on your disk.\nOn Linux or other Unix-like systems, you can do this with the following command:\n\n[source,bash]\n----\nunzip -d target/jlink-howto target/jlink-howto-dist.zip\n----\n\nInspect the total size of the custom runtime image folder.\nOn Linux or other Unix-like systems, you can do this with the following command:\n\n[source,bash]\n----\ndu -sh target/jlink-howto\n----\n\nOn my machine, the result is 68 MB.\nIn comparison, the total size of the JDK 11 distribution is 312 MB.\n\nIt's time to give the application a try.\nOn Linux or other Unix-like systems, you can do this with the following command:\n\n[source,bash]\n----\ntarget/jlink-howto/bin/java --module io.vertx.howtos.jlink/io.vertx.howtos.jlink.CustomLauncher\n----\n\nOr, you can use the generated `server` script:\n\n[source,bash]\n----\ntarget/jlink-howto/bin/server\n----\n\nYou should see something like:\n\n----\nFeb 03, 2025 6:48:31 PM io.vertx.howtos.jlink.ServerVerticle lambda$start$1\nINFO: HTTP server started on port 8888\nFeb 03, 2025 6:48:31 PM io.vertx.launcher.application.VertxApplication\nINFO: Succeeded in deploying verticle\n----\n\nNow, browse to http://localhost:8888 and verify that a greeting is displayed in the browser.\n\n[NOTE]\n====\nWhen the launcher script is used, it's not possible to specify VM options (heap size, remote debugging, etc.) as arguments.\n\nYou can either change the `JLINK_VM_OPTIONS` variable in the `server` script or use the `java` command.\n\nFor example, for remote debugging on Linux or other Unix-like systems:\n\n[source,bash]\n----\ntarget/jlink-howto/bin/java \\\n  -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 \\\n  --module io.vertx.howtos.jlink/io.vertx.howtos.jlink.CustomLauncher\n----\n====\n\n== Summary\n\nThis document covered:\n\n. creating a modular Vert.x Web application,\n. assembling a custom runtime image with jlink.\n\n== See also\n\n* The https://vertx.io/docs/guides/modular-vertx-guide/[Modular Vert.x Guide]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertx-howtos%2Fjlink-howto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvertx-howtos%2Fjlink-howto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertx-howtos%2Fjlink-howto/lists"}