how to make a run.bat file for minecraft server – Code Example

Total
0
Shares

Get the code for including in your run.bat file for running minecraft server. This code could be run on Java console or you can save it as bat file and run through command line in windows OS.

Code Example –

1 – If you want to set server title, No GUI and Java included in system path –

@echo off
title server_name_here
java -Xms512M -Xmx2G -jar SERVER_FILE_NAME.jar nogui
PAUSE

Change server_name_here with any name you want to give to your server. Also replace SERVER_FILE_NAME with the server file name on your system.

2 – If java is not in system path or you don’t have idea about it –

@echo off
title server_name_here
"C:\Program Files (x86)\Java\jre1.8.0_341\bin\java" -Xms512M -Xmx2G -jar SERVER_FILE_NAME.jar nogui
PAUSE

In this command we have use the absolute path of java.exe. You will need the JRE not JDK. On my system jre1.8.0_341 is installed but it could be different for your system and that’s completely fine. Check out this image –

Locating java.exe from jre on windows system

3. If want to run server without providing server name –

"C:\Program Files (x86)\Java\jre1.8.0_341\bin\java" -Xms512M -Xmx2G -jar SERVER_FILE_NAME.jar nogui
PAUSE

Understanding the command –

  • "C:\Program Files (x86)\Java\jre1.8.0_341\bin\java" – Location of java.exe on my system. Should be in double quotes.
  • -Xms512M – Minimum amount of RAM for startup. Here we provided 512 MB.
  • -Xmx2G – Maximum amount of RAM it can take. We provided 2 GB.
  • SERVER_FILE_NAME.jar – Name of jar file for running minecraft server.
  • nogui – Use this flag if you don’t want to run server GUI.
  • PAUSE – To not abruptly close the terminal.

Create a file in notepad++ and save it as run.bat. Put the above command in it and double click to run your server.