User Tools

Site Tools


Preparing minimal Java Runtime Environment

Standard distribution of Java Runtime Environment (JRE) unpacks to around 125MB. This can be significantly reduced by only including those JRE components that are actually used by Workcraft. For this we use Java Development Kit (JDK), preferably the one from, and an unpacked Workcraft distribution.

RedHat7 and CentOS 7 use GCLIB v2.17, which is incompatible with *.so files in openjdk-11-jdk package from Ubuntu 18.04 and newer – they require GLIBC v2.27. Therefore, minimal JRE should be created either using locally installed JDK from (its *.so files are compatible with GLIBC v2.17), or using openjdk-11-jdk package in Ubuntu 16.04 (which is still based on “old enough” GLIBC v2.23).

Print module dependencies of all Workcraft bin/*.jar files with their dependencies located in lib/:

jdeps --recursive --print-module-deps --ignore-missing-deps --multi-release base --class-path lib/* bin/*

The reported dependencies are as follows:


The reported dependencies can be explained as follows:

  • java.base, java.desktop - core functionality
  • java.compiler - used in Rhino library for JavaScript support
  • jdk.xml.dom - used in xml-apis-ext for SVG support
  •, java.naming, java.sql - used in log4j which is needed by SON Plugin and Apache Batik (specifically for PDF Transcoder, and maybe something else)

Another dependency reported on one-by-one analysis of lib/*jar libraries (affected functionality is probably not used in Workcraft):

  • java.logging – used in common-logging and javax.activation libraries

Create minimal JRE with specific modules as follows:

jlink --output jre --strip-debug --no-man-pages --no-header-files --compress=2 \
--add-modules java.base,java.compiler,java.desktop,,java.naming,java.sql,jdk.xml.dom,java.logging

In Linux (depending on the used JDK) some of *.so files in the produced JRE are significantly larger than expected. This is a known problem and the solution is to strip dynamic libraries and binaries of debug symbols. In some cases it helped to reduce JRE size from 450M to 45M:

strip --preserve-dates --strip-unneeded jre/lib/*.so jre/lib/server/*.so jre/bin/java jre/bin/keytool
Copyright © 2014-2024

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki