Skip to content
ApisMC

Java 25+ AOT

Configuring Java 25+ AOT Cache and running Apis directly without manual classpath scripts.

Apis supports Ahead-of-Time (AOT) Cache on Java 25 and newer (Java 25, 26, 27+) out of the box without shell loops over libraries/*.jar or custom wrappers.

  1. META-INF/MANIFEST.MF inside the unpacked server JAR (versions/<mcVersion>/apis-<mcVersion>.jar) already includes:
    • Main-Class: org.bukkit.craftbukkit.Main
    • Multi-Release: true
    • Class-Path - full relative paths to every runtimeClasspath dependency (including apis-api) in ../../libraries/<group>/<module>/<version>/<fileName> format, matching the exact layout unpacked by Paperclip.
  2. CreateBundlerJar also sets Enable-Native-Access: ALL-UNNAMED.
  3. Standard Paperclip boots use cache/.paperclip-stamp (PaperclipStamp) to check size, mtimeMillis, and manifest SHA-256 instead of re-hashing ~100 MB of libraries on every start.

This script removes old cache files, boots the server to record class loading (-XX:AOTMode=record), sends stop automatically after Done ( appears in the log, and compiles cache/apis-cp.aot:

aot.sh
#!/bin/sh
set -e
mkdir -p cache logs
rm -f cache/apis-cp.aot cache/apis-cp.aotconfig /tmp/apis_aot
: > logs/latest.log
mkfifo /tmp/apis_aot
exec 3<>/tmp/apis_aot
(
while ! grep -q "Done (" logs/latest.log 2>/dev/null; do
sleep 0.2
done
sleep 1
echo "stop" >&3
) &
java \
-Xms2G -Xmx3G \
-XX:+UseG1GC -XX:MaxGCPauseMillis=20 \
--enable-native-access=ALL-UNNAMED \
-XX:AOTMode=record \
-XX:AOTConfiguration="cache/apis-cp.aotconfig" \
-cp "versions/<mcVersion>/apis-<mcVersion>.jar" \
org.bukkit.craftbukkit.Main --nogui </tmp/apis_aot
exec 3>&-
rm -f /tmp/apis_aot
java \
-XX:+UseG1GC -XX:MaxGCPauseMillis=20 \
--enable-native-access=ALL-UNNAMED \
-XX:AOTMode=create \
-XX:AOTConfiguration="cache/apis-cp.aotconfig" \
-XX:AOTCache="cache/apis-cp.aot" \
-cp "versions/<mcVersion>/apis-<mcVersion>.jar"

Once cache/apis-cp.aot is compiled, start the server directly with the cache attached:

start.sh
#!/bin/sh
set -e
exec java \
-XX:ThreadPriorityPolicy=1 \
-Xms2G -Xmx3G \
-XX:+UseG1GC -XX:MaxGCPauseMillis=50 \
-Dfile.encoding=UTF-8 \
--enable-native-access=ALL-UNNAMED \
-XX:AOTCache="cache/apis-cp.aot" \
-cp "versions/<mcVersion>/apis-<mcVersion>.jar" \
org.bukkit.craftbukkit.Main --nogui
Mode Command Best For
Standard Paperclip java --enable-native-access=ALL-UNNAMED -jar apis-paperclip-*.jar --nogui First unpack of versions/ & libraries/, quick JAR upgrades via cache/.paperclip-stamp
Direct AOT (AOTCache) java -XX:AOTCache=cache/apis-cp.aot --enable-native-access=ALL-UNNAMED -cp versions/<mcVersion>/apis-<mcVersion>.jar org.bukkit.craftbukkit.Main --nogui Fastest cold start and warmup inside Docker / Kubernetes containers