Skip to content

Commit 0440de3

Browse files
wfouchemaxandersen
andauthored
docs: document how to create native images using jbundle (jbangdev#2382)
* docs: document how to create native images using jbundle * Fixed typo * Removed blank line * Moved jbundle content to a separate page * Remove jbundle content from graalvm page * Fix jbundle build command * Add limitations section * Remove --no-appcds option * Added new Configuration section * JBundle creates self-contained binaries * docs: binaries -> executables * Fixed nav.adoc * Changed binary to executable --------- Co-authored-by: Max Rydahl Andersen <max@xam.dk>
1 parent 014885b commit 0440de3

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
= Self-Contained Executables
2+
:idprefix:
3+
:idseparator: -
4+
ifndef::env-github[]
5+
:icons: font
6+
endif::[]
7+
ifdef::env-github[]
8+
:caution-caption: :fire:
9+
:important-caption: :exclamation:
10+
:note-caption: :paperclip:
11+
:tip-caption: :bulb:
12+
:warning-caption: :warning:
13+
endif::[]
14+
15+
Self-contained executables are executables that you can run without needing a pre-existing runtime to be installed.
16+
17+
GraalVM's native-image is one way of doing this, but GraalVM also deal with optimizing the runtime for performance by doing additional compilation/optimization.
18+
19+
This section is not about GraalVM's native-image, but about other ways of creating self-contained executables.
20+
21+
== JBundle
22+
23+
https://jbundle.avelino.run/[JBundle] can be used with JBang to compile your Java scripts into standalone self-contained executables.
24+
25+
== Why JBundle?
26+
27+
GraalVM's native-image can be challenging to use due to slow compilations, reflection configurations, and libraries that might not work well in native image.
28+
29+
JBundle offers a practical and easy to use solution by bundling a minimal JVM runtime with your uberjar into a single executable. The result is a single executable file, without any external dependencies, and with full JVM compatibility.
30+
31+
=== Creating Self-Contained Executables with JBundle
32+
33+
https://jbundle.avelino.run/[JBundle] makes it easy to create self-contained executables from JBang applications without the need for complex configuration. JBundle uses `jlink` to analyze your application and its dependencies, then generates a self-contained executable file with a minimal embedded JVM runtime providing only the necessary modules required by your application.
34+
35+
* Step 0 - Create a JBang script (or use an existing application)
36+
** jbang init hello.java
37+
* Step 1 - create a JBang fatjar
38+
** jbang export fatjar hello.java
39+
* Step 2 - use JBundle to create a self-contained executable from the fatjar
40+
** jbundle build --input ./hello-fatjar.jar --output ./dist/hello
41+
* Step 3 - run the self-contained binary file
42+
** ./dist/hello
43+
+
44+
Hello World
45+
46+
=== JBundle Configuration
47+
48+
Additional https://jbundle.avelino.run/user-guide/configuration[configuration options] can be specified on the command-line or stored in a `jbundle.toml` file in the local folder.
49+
50+
```toml
51+
# jbundle.toml
52+
53+
java_version = 25
54+
profile = "server"
55+
jvm_args = ["-Xmx512m", "-XX:+UseZGC"]
56+
shrink = true
57+
appcds = false
58+
crac = false
59+
```
60+
61+
=== Limitations
62+
63+
JBundle is currently only supported on Linux and MacOS.

docs/modules/ROOT/partials/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
** xref:jbang:ROOT:execution-options.adoc[Execution Options]
1818
** xref:jbang:ROOT:remote-execution.adoc[Remote Execution]
1919
** xref:jbang:ROOT:native-images.adoc[Native Images]
20+
** xref:jbang:ROOT:self-contained-executables.adoc[Self-Contained Executables]
2021
** xref:jbang:ROOT:editing.adoc[IDE Integration]
2122
2223
* Distribution & Deployment

0 commit comments

Comments
 (0)