2019-02-01 12:36:40 +01:00
# Warp4j
2019-02-14 17:08:36 +01:00
Turn JAR (java archive) into self-contained executable in a single command.
2019-02-01 12:36:40 +01:00
## Features
2024-05-31 15:08:43 +02:00
- Downloads Java runtimes automatically
- Makes runtimes optimized for your application
- Creates self-contained binaries for Linux, macOS, and Windows using [warp-packer ](https://git.phoenix.ipv64.de/public/warp )
- Works on Linux, macOS, and Windows (with Windows Subsystem for Linux)
- Supports cross "compilation"
- Does not require either JDK or JRE installed
2019-02-01 12:36:40 +01:00
2019-02-11 17:19:59 +01:00
## TL;DR
Just put both `warp4j` and `warp-packer` somewhere in your PATH and run `warp4j app.jar` .
2019-02-01 12:36:40 +01:00
## Install
2024-05-31 15:08:43 +02:00
Curl one-liner installs the latest versions of both `warp4j` and `warp-packer` :
2019-02-14 18:43:19 +01:00
2024-05-31 15:08:43 +02:00
```sh
2024-05-20 19:57:06 +02:00
bash -c "$(curl -fsSL https://git.phoenix.ipv64.de/public/warp4j/raw/branch/master/install.sh)"
2019-02-14 18:43:19 +01:00
```
2024-05-31 15:08:43 +02:00
This script will show missing dependencies (if there are any); they must be installed with your package manager.
2019-02-01 12:36:40 +01:00
2019-02-16 20:12:03 +01:00
See more install methods [here ](INSTALL.md ).
2019-02-14 17:08:36 +01:00
2019-02-01 12:36:40 +01:00
## Usage
2024-05-31 15:08:43 +02:00
```sh
2019-02-01 12:36:40 +01:00
$ ls
my-app.jar
$ warp4j my-app.jar
...
...
...
2019-02-01 21:01:53 +01:00
$ ls -1
my-app.jar
warped
$ ls warped
2019-02-18 15:37:27 +01:00
my-app-linux-x64
2019-02-11 17:19:59 +01:00
my-app-linux-x64.tar.gz
2019-02-18 15:37:27 +01:00
my-app-macos-x64
2019-02-11 17:19:59 +01:00
my-app-macos-x64.tar.gz
2019-02-18 15:37:27 +01:00
my-app-windows-x64.exe
2019-02-11 17:19:59 +01:00
my-app-windows-x64.zip
2019-02-01 21:01:53 +01:00
```
See help:
2024-05-31 15:08:43 +02:00
```sh
$ warp4j --help
2024-05-20 19:57:06 +02:00
2019-02-11 17:19:59 +01:00
Usage: warp4j [options] < app.jar >
2024-05-31 15:08:43 +02:00
Turn JAR (java archive) into a self-contained executable
2019-02-11 17:19:59 +01:00
Options:
-j, --java-version < version >
2024-05-31 15:08:43 +02:00
Override JDK/JRE version
Examples: "17", "17.0", "17.0.2", "17.0.2+9"
2022-08-12 18:40:09 +02:00
(default: 17)
-cp, --class-path < classpath >
2024-05-31 15:08:43 +02:00
Adds additional classpaths to the jdeps call
--auto-class-path Extract and get class-path values from jar file
Ignored when -cp, --class-path is set
--spring-boot Extract and get class-path values from
2024-05-20 19:57:06 +02:00
Spring-Boot application jar file
2024-05-31 15:08:43 +02:00
Ignored when -cp, --class-path is set
2019-02-15 10:36:51 +01:00
-o, --output < directory >
2024-05-31 15:08:43 +02:00
Override output directory;
This is relative to current PWD
2019-02-15 10:36:51 +01:00
(default: ./warped)
2024-05-20 19:57:06 +02:00
-p, --prefix < prefix >
2024-05-31 15:08:43 +02:00
If set, warp-packer will use the prefix
2024-06-01 19:02:02 +02:00
as target folder in which the
2024-05-20 19:57:06 +02:00
application should be extracted
2024-05-31 15:08:43 +02:00
--list Show available java releases;
Takes into consideration other options:
2019-02-17 11:56:58 +01:00
"--java-version", "--no-optimize", "--jvm-impl";
2024-05-31 15:08:43 +02:00
The output may be used to specify concrete
2019-02-17 11:56:58 +01:00
"--java-version"
2024-06-01 19:02:02 +02:00
--add-modules A list of additional java modules that should
be added to the optimized JDK. Separate each
module with commas and no spaces
2024-05-31 15:08:43 +02:00
--no-optimize Use JRE instead of optimized JDK;
By default jdeps and jlink are used to create
2019-02-18 15:37:27 +01:00
optimized JDK for the particular jar;
2019-02-11 17:19:59 +01:00
JRE is always used for java 8
2024-05-31 15:08:43 +02:00
--pull Check if more recent JDK/JRE distro is available;
By default latest cached version that matches
2019-02-11 17:19:59 +01:00
"--java-version" is used
2024-05-31 15:08:43 +02:00
--linux Create binary for Linux
--macos Create binary for macOS
--windows Create binary for Windows
If no targets are specified then binaries for
2019-02-14 17:08:36 +01:00
all targets are created
2019-02-11 17:19:59 +01:00
--jvm-options < options >
2024-05-31 15:08:43 +02:00
Passed to java like this:
2019-02-18 15:37:27 +01:00
"java < options > -jar < jar file > ";
2024-05-31 15:08:43 +02:00
Use quotes when passing multiple options
Example: '-Xms512m -Xmx1024m'
-s, --silent Using javaw instead of java for windows
-h, --help Show this message
2019-02-01 12:36:40 +01:00
```
2024-05-31 15:08:43 +02:00
### Running on macOS
For macOS, the executable is placed inside a folder with the `.app` extension within the tar.gz file. This allows the application to be launched with a double-click.
To run the application:
1. **From the Executable** :
- Navigate to the `warped` folder.
- Find the `my-app-macos-x64` executable.
- Note: Double-clicking on “my-app-macos-x64” does not work directly because macOS does not know which program to use to open the application.
- To run it, open the terminal and navigate to the `warped` folder:
```sh
cd /path/to/warped
```
- Run the executable from the terminal:
```sh
./my-app-macos-x64
```
2. **From the tar.gz File** :
- Extract the `my-app-macos-x64.tar.gz` file.
- Navigate to the extracted folder: `my-app-macos-x64` .
- You will find a folder named `my-app.app` . For macOS this is now an executable file.
- Double-click on `my-app.app` to run the application.
2019-02-14 17:08:36 +01:00
## Compatibility
Tested on the following operating systems:
2024-05-20 21:47:21 +02:00
- Debian 12.5
2019-02-14 17:08:36 +01:00
2019-02-01 12:36:40 +01:00
## Cache Location
2019-02-11 17:19:59 +01:00
Downloaded runtimes and prepared bundles are here:
2019-02-01 12:36:40 +01:00
2019-02-11 17:19:59 +01:00
- Linux: `$HOME/.local/share/warp4j`
- macOS: `$HOME/Library/Application Support/warp4j`
2019-02-18 15:37:27 +01:00
2024-05-31 15:08:43 +02:00
To override cache path, set `WARP4J_CACHE` environment variable.