How to prepare start.bat or start.sh for Minecraft server?

The initialization file ensures that you use the same jar file, Java path, and memory settings every time you boot. Keep file format separate for Windows and Linux.

Step by step

  1. Check the actual name of the server jar file. For example, if you are using paper.jar, type the same name in the command.

  2. In Windows, open start.bat in the server directory. Write cd /d "%~dp0" on the first line and java -Xms1G -Xmx3G -jar paper.jar --nogui on the second line.

  3. On Linux, put #!/bin/sh in the first line of the start.sh file and use the same Java command. While in the server directory, run it with sh start.sh.

  4. Check that it is opened with the correct jar and working directory in the console. Log in locally and close regularly with stop from the console.

Keep in mind

-Xmx is not the entire machine memory. Leave space for non-heap usage of the operating system and Java.

Source and tools