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.
Why AOT Works Directly on Apis
Section titled “Why AOT Works Directly on Apis”META-INF/MANIFEST.MFinside the unpacked server JAR (versions/<mcVersion>/apis-<mcVersion>.jar) already includes:Main-Class: org.bukkit.craftbukkit.MainMulti-Release: trueClass-Path- full relative paths to everyruntimeClasspathdependency (includingapis-api) in../../libraries/<group>/<module>/<version>/<fileName>format, matching the exact layout unpacked by Paperclip.
CreateBundlerJaralso setsEnable-Native-Access: ALL-UNNAMED.- Standard Paperclip boots use
cache/.paperclip-stamp(PaperclipStamp) to checksize,mtimeMillis, and manifest SHA-256 instead of re-hashing ~100 MB of libraries on every start.
Step 1. Record & Compile the AOT Cache
Section titled “Step 1. Record & Compile the AOT Cache”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:
#!/bin/shset -e
mkdir -p cache logsrm -f cache/apis-cp.aot cache/apis-cp.aotconfig /tmp/apis_aot: > logs/latest.log
mkfifo /tmp/apis_aotexec 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"New-Item -ItemType Directory -Force cache, logs | Out-NullRemove-Item -Force -ErrorAction SilentlyContinue cache/apis-cp.aot, cache/apis-cp.aotconfigNew-Item -ItemType File -Force logs/latest.log | Out-Null
$p = New-Object System.Diagnostics.Process$p.StartInfo.FileName = "java"$p.StartInfo.Arguments = '-Xms2G -Xmx3G -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -Dfile.encoding=UTF-8 --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'$p.StartInfo.UseShellExecute = $false$p.StartInfo.RedirectStandardInput = $true$p.Start() | Out-Null
while (-not $p.HasExited -and -not (Select-String -Path logs/latest.log -Pattern "Done \(" -Quiet)) { Start-Sleep -Milliseconds 200}if (-not $p.HasExited) { Start-Sleep -Seconds 1 $p.StandardInput.WriteLine("stop")}$p.WaitForExit()
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"Step 2. Production Launch with AOTCache
Section titled “Step 2. Production Launch with AOTCache”Once cache/apis-cp.aot is compiled, start the server directly with the cache attached:
#!/bin/shset -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 --noguijava ` -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 --noguiStartup Mode Comparison
Section titled “Startup Mode Comparison”| 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 |