How to Run a Minecraft Server Jar

Updated · MCJarHub

Open a terminal in the server folder and run java -Xms4G -Xmx4G -jar server.jar nogui. Put that line in start.bat (Windows) or start.sh (Linux/macOS) so you can start the server with a double-click or one command.

The command

java -Xms4G -Xmx4G -jar server.jar nogui
  • java — the Java runtime. It must be the version your Minecraft version needs (table). If several are installed, use the full path, e.g. "C:\Program Files\Eclipse Adoptium\jdk-21…\bin\java.exe" or /usr/lib/jvm/…/bin/java.
  • -Xms4G -Xmx4G — initial and maximum heap memory. Setting both to the same value is what PaperMC recommends for dedicated servers. See how much RAM.
  • -jar server.jar — the server file; replace it with your file name (for example paper-1.21.11-132.jar).
  • nogui — don't open the vanilla console window; run in the terminal only.

Run it from inside the server folder: the server uses the current directory for the world, server.properties and logs.

Windows: start.bat

Create a text file named start.bat in the server folder (make sure Windows doesn't save it as start.bat.txt) with:

@echo off
cd /d "%~dp0"
java -Xms4G -Xmx4G -jar server.jar nogui
pause

cd /d "%~dp0" switches to the script's folder, so a double-click works from anywhere; pause keeps the window open so you can read errors.

Linux / macOS: start.sh

#!/bin/sh
cd "$(dirname "$0")"
java -Xms4G -Xmx4G -jar server.jar nogui

Make it executable once with chmod +x start.sh, then run ./start.sh. On a remote server, start it inside screen or tmux so it keeps running after you disconnect:

tmux new -s mc ./start.sh      # detach: Ctrl+B then D, re-attach: tmux attach -t mc

Automatic restart after a crash or /stop

Linux/macOS:

#!/bin/sh
cd "$(dirname "$0")"
while true; do
  java -Xms4G -Xmx4G -jar server.jar nogui
  echo "Server stopped. Restarting in 10 seconds (Ctrl+C to cancel)…"
  sleep 10
done

Windows:

@echo off
cd /d "%~dp0"
:start
java -Xms4G -Xmx4G -jar server.jar nogui
echo Server stopped. Restarting in 10 seconds (close the window to cancel)...
timeout /t 10
goto start

Types that start differently

  • Forge 1.17+ and NeoForge: there is no single jar to run. The installer creates run.sh/run.bat, and memory goes into user_jvm_args.txt — see the Forge and NeoForge guides.
  • Fabric: run the Fabric server launcher jar like any server jar; it downloads the vanilla server on first start (guide).
  • Spigot/CraftBukkit: build the jar with BuildTools first (guide), then run it as above.
  • Proxies (Velocity, BungeeCord): same command without nogui and with much less memory (512 MB–1 GB); no EULA.

Paper, Purpur and Folia benefit from Aikar's G1 flags; every version page on MCJarHub includes a ready start script with them, and the start script generator builds one for your RAM, OS and server type.

FAQ

What does nogui do?
It stops the vanilla server from opening its small Swing console window, so the server runs only in the terminal. Paper accepts --nogui as well.
Why does double-clicking the jar do nothing?
Either no Java (or the wrong Java) is installed, or the jar is opened by another program. Use a start script — see server jar not opening.
Should -Xms equal -Xmx?
For a dedicated server, yes: PaperMC recommends setting both to the same value so the memory is reserved up front.