{"id":94,"date":"2025-12-29T13:51:13","date_gmt":"2025-12-29T13:51:13","guid":{"rendered":""},"modified":"2025-12-29T13:51:13","modified_gmt":"2025-12-29T13:51:13","slug":"minecraft-startup-scripts-java-flags","status":"publish","type":"post","link":"https:\/\/minecraftserverslist.co\/blog\/minecraft-startup-scripts-java-flags\/","title":{"rendered":"Minecraft Server Startup Scripts &#038; Java Flags Guide 2025"},"content":{"rendered":"<p>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.<\/p>\n<h2>What Are Java Flags?<\/h2>\n<p>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.<\/p>\n<h2>Essential Startup Parameters<\/h2>\n<h3>Memory Allocation<\/h3>\n<pre><code>-Xms4G -Xmx4G<\/code><\/pre>\n<p><strong>-Xms<\/strong>: Minimum (starting) memory<br \/>\n<strong>-Xmx<\/strong>: Maximum memory allocation<\/p>\n<p><em>Tip: Set both values equal for consistent performance.<\/em><\/p>\n<h3>RAM Recommendations<\/h3>\n<p>\u2022 10-20 players: 4GB<br \/>\n\u2022 20-50 players: 6-8GB<br \/>\n\u2022 50-100 players: 8-12GB<br \/>\n\u2022 100+ players: 12-16GB<\/p>\n<h2>Aikar&#8217;s Flags Explained<\/h2>\n<p>Aikar&#8217;s flags are the gold standard for Minecraft servers, officially recommended by PaperMC.<\/p>\n<h3>For Servers Under 12GB<\/h3>\n<pre><code>java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled \n-XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions \n-XX:+DisableExplicitGC -XX:+AlwaysPreTouch \n-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 \n-XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 \n-XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 \n-XX:InitiatingHeapOccupancyPercent=15 \n-XX:G1MixedGCLiveThresholdPercent=90 \n-XX:G1RSetUpdatingPauseTimePercent=5 \n-XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem \n-XX:MaxTenuringThreshold=1 -jar server.jar --nogui<\/code><\/pre>\n<h3>For 12GB+ Servers<\/h3>\n<p>Use larger G1 region sizes:<\/p>\n<pre><code>-XX:G1NewSizePercent=40 \n-XX:G1MaxNewSizePercent=50 \n-XX:G1HeapRegionSize=16M \n-XX:G1ReservePercent=15<\/code><\/pre>\n<h2>Understanding Key Flags<\/h2>\n<h3>Garbage Collection<\/h3>\n<p><strong>-XX:+UseG1GC<\/strong>: Uses G1 garbage collector, optimized for low pause times.<\/p>\n<p><strong>-XX:MaxGCPauseMillis=200<\/strong>: Target maximum GC pause of 200ms.<\/p>\n<h3>Memory Pre-touch<\/h3>\n<p><strong>-XX:+AlwaysPreTouch<\/strong>: Allocates all memory at startup, preventing allocation lag during gameplay.<\/p>\n<h3>Performance Optimization<\/h3>\n<p><strong>-XX:+DisableExplicitGC<\/strong>: Prevents plugins from forcing garbage collection.<br \/>\n<strong>-XX:+ParallelRefProcEnabled<\/strong>: Multi-threaded reference processing.<\/p>\n<h2>Alternative Flag Sets<\/h2>\n<h3>MeowIce&#8217;s Flags (GraalVM)<\/h3>\n<p>Optimized for GraalVM with ZGC garbage collector. Best for high player counts:<\/p>\n<pre><code>-XX:+UseZGC -XX:+ZGenerational -XX:+AlwaysPreTouch<\/code><\/pre>\n<h3>Velocity Proxy Flags<\/h3>\n<p>For Velocity\/BungeeCord proxy servers:<\/p>\n<pre><code>-XX:+UseG1GC -XX:G1HeapRegionSize=4M \n-XX:+UnlockExperimentalVMOptions -XX:+ParallelRefProcEnabled<\/code><\/pre>\n<h2>Operating System Scripts<\/h2>\n<h3>Linux\/macOS (start.sh)<\/h3>\n<pre><code>#!\/bin\/bash\njava -Xms4G -Xmx4G [flags] -jar server.jar --nogui<\/code><\/pre>\n<h3>Windows (start.bat)<\/h3>\n<pre><code>@echo off\njava -Xms4G -Xmx4G [flags] -jar server.jar --nogui\npause<\/code><\/pre>\n<h3>With Auto-Restart<\/h3>\n<pre><code>#!\/bin\/bash\nwhile true; do\n    java -Xms4G -Xmx4G [flags] -jar server.jar --nogui\n    echo \"Server stopped. Restarting in 5 seconds...\"\n    sleep 5\ndone<\/code><\/pre>\n<h2>Common Mistakes to Avoid<\/h2>\n<p>\u274c Allocating more RAM than your system has<br \/>\n\u274c Using outdated Java versions<br \/>\n\u274c Mixing incompatible flags<br \/>\n\u274c Setting -Xms much lower than -Xmx<br \/>\n\u274c Not using &#8211;nogui on headless servers<\/p>\n<h2>Quick Start Checklist<\/h2>\n<p>\u2705 Use Java 21+ for best performance<br \/>\n\u2705 Match -Xms and -Xmx values<br \/>\n\u2705 Use Paper\/Purpur server software<br \/>\n\u2705 Apply Aikar&#8217;s flags for your RAM tier<br \/>\n\u2705 Include &#8211;nogui for console servers<br \/>\n\u2705 Test TPS after making changes<\/p>\n<p><strong>Generate your startup script!<\/strong> Use our free <a href=\"https:\/\/minecraftserverslist.co\/tools\/flags-generator\">Flags Generator Tool<\/a> to create optimized startup scripts for any OS and server type!<\/p>\n<p>Need more optimization tips? Check out our guide on <a href=\"https:\/\/minecraftserverslist.co\/blog\/\">reducing server lag<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Master Minecraft server optimization with Aikar&#8217;s flags and custom startup scripts. Complete guide to Java flags, memory allocation, and performance tuning.<\/p>\n","protected":false},"author":1,"featured_media":100,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-94","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":0,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/media\/100"}],"wp:attachment":[{"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/minecraftserverslist.co\/blog\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}