jlink wrapper that creates custom minimalistic JRE with selected modules only.
Kastomize creates JVM without man pages, headers and debug attributes as they are hardly needed to run application.
- Download the latest release and make it executable
wget https://github.com/kyberorg/kastomize/releases/download/1.0/kastomize
chmod +x kastomize
- Create you module file
Tip: you can find out required options by running jdeps your_app.jar
cat <<EOF > modulesfile
java.base
java.logging
java.sql
EOF
- Finally, run kastomize
./kastomize --modules-file modulesfile --output myjre
- Find your custom-made JVM is ready at
myjre
folder
ls -al ./myjre
- You can set custom JDK folder by defining
--java-home
option orJAVA_HOME
environment var.
./kastomize --modules-file modulesfile --output myjre --java-home /path/to/my/jdk
- Absolute path are also supported
./kastomize --modules-file /path/to/modulesfile --output /path/to/myjre
- Normal build
make binary
If size really matters try to pack binary with upx.
For version 1.1
binary size reduced by 30.91%
make small-binary
or
make binary upx
CGO_ENABLED=0 go build github.com/kyberorg/kastomize/cmd/kastomize