Skip to content

Commit c79b260

Browse files
committed
Describe design decision for native binaries
1 parent 580c86c commit c79b260

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Native Binaries
2+
3+
## Context and Problem Statement
4+
5+
The SDK's command line interface should be usable as convenient to use as possible, i.e., it should
6+
be usable without requiring a user to have a certain version of Java installed. It should also be
7+
directly launchable, i.e., by typing its name (without the `java -jar` incantation).
8+
9+
## Decision Drivers
10+
11+
* CLI should be runnable without having Java installed.
12+
* CLI should be directly executable (i.e., without calling `java -jar`).
13+
* Beneficial: CLI should respond quickly, in particluar when showing help texts.
14+
15+
Note: A more detailed explanation of those points can be found in the blog post [Building a decent
16+
Java CLI](https://atextor.de/2020/07/27/building-a-decent-java-cli.html).
17+
18+
## Considered Options
19+
20+
* Regular executable .jar with custom launcher script and bundled JRE.
21+
* Advantages
22+
* .jar file can work as-is.
23+
* Flexibility to adjust script.
24+
* Disadvantages
25+
* Binary can not be distributed on its own; it will always need a complete folder (containing
26+
the JRE).
27+
* Overall startup time: startup time of the .exe + startup time of the JVM.
28+
* [Launch4J](https://launch4j.sourceforge.net/index.html):
29+
* Remarks
30+
* Effectively provides a native binary that optionally extracts an executable .jar from itself,
31+
then lauches the .jar using Java.
32+
* Advantages
33+
* .jar file can work as-is.
34+
* Out-of-the-box solution including Maven plugin.
35+
* Disadvantages
36+
* Binary can not be distributed on its own; it will always need a complete folder (containing
37+
the JRE).
38+
* Overall startup time: startup time of the .exe + startup time of the JVM.
39+
* [GraalVM Native Image](https://www.graalvm.org/latest/reference-manual/native-image/basics/):
40+
* Remarks
41+
* Project driven by Oracle to create native binaries from Java applications, including compiler,
42+
custom runtime (that will be baked into the binary) and accompanying tooling such as source
43+
annotations.
44+
* Advantages
45+
* "Official" project with support present or coming in major frameworks.
46+
* Proper tooling available (Maven plugin, Github actions, etc.).
47+
* Can produce standalone binaries.
48+
* Startup time overhead is removed/reduced.
49+
* Disadvantages
50+
* Additional configuration effort for resources, reflection, JNI,...
51+
52+
## Decision Outcome
53+
54+
Chosen option: "GraalVM Native Image", because only this option will provide a quickly starting,
55+
self-contained binary.
56+

0 commit comments

Comments
 (0)