Minecraft Server Startup Scripts & Java Flags Guide 2025
Optimizing your Minecraft server startup script is one of the easiest ways to improve performance. This guide explains Java flags and how to create the perfect startup script.
What Are Java Flags?
Java flags are command-line arguments that control how the Java Virtual Machine (JVM) runs your server. They affect memory management, garbage collection, and overall performance.
Essential Startup Parameters
Memory Allocation
-Xms4G -Xmx4G-Xms: Minimum (starting) memory
-Xmx: Maximum memory allocation
Tip: Set both values equal for consistent performance.
RAM Recommendations
• 10-20 players: 4GB
• 20-50 players: 6-8GB
• 50-100 players: 8-12GB
• 100+ players: 12-16GB
Aikar’s Flags Explained
Aikar’s flags are the gold standard for Minecraft servers, officially recommended by PaperMC.
For Servers Under 12GB
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled
-XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions
-XX:+DisableExplicitGC -XX:+AlwaysPreTouch
-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40
-XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20
-XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4
-XX:InitiatingHeapOccupancyPercent=15
-XX:G1MixedGCLiveThresholdPercent=90
-XX:G1RSetUpdatingPauseTimePercent=5
-XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem
-XX:MaxTenuringThreshold=1 -jar server.jar --noguiFor 12GB+ Servers
Use larger G1 region sizes:
-XX:G1NewSizePercent=40
-XX:G1MaxNewSizePercent=50
-XX:G1HeapRegionSize=16M
-XX:G1ReservePercent=15Understanding Key Flags
Garbage Collection
-XX:+UseG1GC: Uses G1 garbage collector, optimized for low pause times.
-XX:MaxGCPauseMillis=200: Target maximum GC pause of 200ms.
Memory Pre-touch
-XX:+AlwaysPreTouch: Allocates all memory at startup, preventing allocation lag during gameplay.
Performance Optimization
-XX:+DisableExplicitGC: Prevents plugins from forcing garbage collection.
-XX:+ParallelRefProcEnabled: Multi-threaded reference processing.
Alternative Flag Sets
MeowIce’s Flags (GraalVM)
Optimized for GraalVM with ZGC garbage collector. Best for high player counts:
-XX:+UseZGC -XX:+ZGenerational -XX:+AlwaysPreTouchVelocity Proxy Flags
For Velocity/BungeeCord proxy servers:
-XX:+UseG1GC -XX:G1HeapRegionSize=4M
-XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabledOperating System Scripts
Linux/macOS (start.sh)
#!/bin/bash
java -Xms4G -Xmx4G [flags] -jar server.jar --noguiWindows (start.bat)
@echo off
java -Xms4G -Xmx4G [flags] -jar server.jar --nogui
pauseWith Auto-Restart
#!/bin/bash
while true; do
java -Xms4G -Xmx4G [flags] -jar server.jar --nogui
echo "Server stopped. Restarting in 5 seconds..."
sleep 5
doneCommon Mistakes to Avoid
❌ Allocating more RAM than your system has
❌ Using outdated Java versions
❌ Mixing incompatible flags
❌ Setting -Xms much lower than -Xmx
❌ Not using –nogui on headless servers
Quick Start Checklist
✅ Use Java 21+ for best performance
✅ Match -Xms and -Xmx values
✅ Use Paper/Purpur server software
✅ Apply Aikar’s flags for your RAM tier
✅ Include –nogui for console servers
✅ Test TPS after making changes
Generate your startup script! Use our free Flags Generator Tool to create optimized startup scripts for any OS and server type!
Need more optimization tips? Check out our guide on reducing server lag!

Leave a Reply