Making a Minecraft Server Batch File

Here’s a quick demo on launching a Minecraft server in Windows using a .bat file.

  1. Right click in your folder and go to New > Text Document.
  2. Name it start_server.bat
  3. Hit Yes when windows asks if you’re sure about changing the extension.
  4. Now right click the file and hit Edit.
  5. Paste in the following text, and change it to match your situation. I’ll explain each part to better help you make the necessary changes.
  • The first bit is a call to your system’s Java installation. It needs to be in quotes because of the space in Program Files (x86). To find yours, look in either your Program Files or Program Files (x86) to find Java.
  • Next are two options that tell Java how much RAM it can use. -Xmx is the maximum, and -Xms is how much it’ll start with. You can specify in Megabytes or Gigabytes.
  • Here’s the -jar option along with the name of your .jar file. Here you can just put the name of the .jar file you want to launch as long as it’s in the same directory as your .bat script.
  • nogui tells the Minecraft server not to start the GUI part of the application. Opening the server through a script means it’ll be running in a console window. There’s no need for a GUI when you have a much better looking terminal to view.
  • PAUSE simply makes the window wait for you to “hit any key to continue…” after you “stop” the server. I like doing this out of habit in certain situations, you can take it or leave it.

By simply changing the .jar file called by this script, you can use it to launch either a vanilla server or a modified server like Forge. I’m not a Windows script pro by any means (I’m usually using Linux), but if you have any questions please feel free to ask in the comments below!

 

 

45 thoughts on “Making a Minecraft Server Batch File

  1. Use the following to launch the version of forge present, rather than having to dit the forge-filename or your sript with each new version of forge you run.

    FOR /f “tokens=*” %%G IN (‘dir /b forge*.jar’) DO java -Xmx6G -Xms6G -jar %%G -Dfml.queryResult=confirm nogui

  2. whenever i start the batch file, my windows says ‘\program’ is not recognized as an internal or external command, operable program or batch file. HELP

  3. Hey, I’ve got a bit of an issue. Whenever I try and change the values to something higher than they are in your example (Xmx512 and Xms1024), the console always has a problem and cant launch the server, when the entire reason I made the batch file was to allocate more ram for the server to use!
    I tried increasing the values to Xmx1024 Xms2048 and got:
    Error occurred during initialization of VM
    Could not reserve enough space for 2097152kb object heap

    And when I increase them to Xmx3072 Xms2048, it says:
    Error occurred during initialization of VM
    Could not reserve enough space for 3145728kb object heap

    And if I try 4096 and 2048, it says:
    Invalid maximum heap size: -Xmx4096M
    The specified size exceeds the maximum representable size.
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occured. Program will exit.

    My computer has 8.00 GB of ram, so options like Xmx1024 Xms2048 to someone who doesn’t understand Java at all like me should seemingly work fine, I don’t understand why it won’t let me increase values. Any input would be appreciated because I don’t understand it, and I can’t find anyone else asking this specific question.

    1. Not sure if you’ve figured it out, but the Xmx is the maximum ram it can use, while Xms is what it starts out with. Make Xms the smaller of the two figures and Xmx the larger, and you should be good.

  4. ok total noob here i downloade the 1.10 from minecrat.net i have a 64bit wind 10 java update 3 days ago and i cant get a batch file to work please help

  5. i keep doing the steps in the correct order. i right click in the folder, i click new -> text document, i name it start_server.bat, then i hit enter but it doesnt ask me if im sure if i want to change the extension. so its not actually making a .bat file its staying at a .txt. can you please help me. ive been trying all day to find a solution

    1. Go to: Control Panel > All Control Panel Items > File Explorer Options > View. Then, uncheck the box “Hide extensions for known file types”

    2. the jar files name has to match the jar file in your folder and they have to be in the same folder it won’t work on your desktop put the entire server into a file then run start_server.bat although the start_server.bat can be named anything

    1. Not sure if you’ve been answered yet, but just remove the ‘nogui’ from the line and it will open the gui as it starts the server.

    1. If you switch between Java 7 and Java 8, I would make two different .bat files. One for each java you want to call. However, you still want to call java.exe. The javaw.exe is used for GUI-based programs, which is why most programs use it. The server is strictly in the terminal and is why you don’t need the ‘w’ version.

  6. im trying to make a vanilla server and i noticed in the code line it say forge server. can i just change that to minecraft server and il be fine or is there another way i have to do it?

    1. Yes I just used forge_server.jar as an example. You can use any server.jar, including the vanilla one. Just make sure to change the line of code to match the name of the .jar you are calling.

    1. Is your .jar file actually named forge_server.jar? This line in your .bat file needs to call the correct file. My example was forge_server.jar but yours could be named anything.

  7. I know it’s been a while, but I’m trying to set up a local server and can’t seem to get the batch file to increase my RAM. Has the process changed in the jre1.8.0_51 version? Also is start_server.bat still appropriate for the forge universal.jar?

  8. When I use the batch file, it says “The system cannot find the path specified.”
    I typed in where my java file was, in quotes, of course.

    1. It’s possible you’re missing a space or maybe you don’t have quotes around the location? You need the quotes to automatically escape any special characters or spaces. Paste your line 1 in a comment here and I’ll look at it to see if I can figure out the problem.

  9. when i change the name to “start_server.bat” it doesn’t ask me anything about a change and it stays as a text document

    1. My first thought is that you have Windows hiding the file extension types. If that’s the case then your file is actually being named “start_server.bat.txt” and would of course stay as a text file. Search google for “Windows show file extensions” for instructions on how to make sure you see them. Let me know if this doesn’t work and I’ll try to help more!

    2. Make sure you click “save as”, choose a name, and last but not least make sure to change the “save as type” from “text document” to “all files” Sorry if this is messy I was typing off memory. Good luck!

  10. No console window:
    @echo off
    start /b javaw -Xmn1G -Xms1G -Xmx2G -XX:NewSize=512M -XX:SurvivorRatio=2 -XX:+DisableExplicitGC -XX:ParallelGCThreads=4 -d64 -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -jar forge-1.7.10-10.13.2.1291-universal.jar

    I don’t know where the exception comes from, it’s annoying but doesn’t prevent the server from running; I will live with it. 🙂

    1. The exception is likely due to all the extra options you’re using. I’m not familiar with them so one of them could be the culprit. Honestly though I don’t understand going through the trouble of getting rid of a console window. Once the server is started it’s no longer a console window, it becomes the server. It gives you info on what’s going on, who’s doing what, etc.

  11. Honestly I beg to differ about the GUI thing, I find the server GUI more useful and more pleasant to look at than the CMD window.
    there is a slight problem though. I changed “java.exe” to “javaw.exe” so I could use the GUI and close the CMD window once the server had been started. However the server spits out this message.

    [12:46:08 ERROR]: Exception handling console input
    java.io.IOException: Not enough storage is available to process this command
    at java.io.FileInputStream.readBytes(Native Method) ~[?:1.7.0_67]
    at java.io.FileInputStream.read(Unknown Source) ~[?:1.7.0_67]
    at java.io.BufferedInputStream.read1(Unknown Source) ~[?:1.7.0_67]
    at java.io.BufferedInputStream.read(Unknown Source) ~[?:1.7.0_67]
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[?:1.7.0_67]
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[?:1.7.0_67]
    at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[?:1.7.0_67]
    at java.io.InputStreamReader.read(Unknown Source) ~[?:1.7.0_67]
    at java.io.BufferedReader.fill(Unknown Source) ~[?:1.7.0_67]
    at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.7.0_67]
    at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.7.0_67]
    at pr.run(SourceFile:81) [PixelIsStranded.jar:?]

    (PixelIsStranded.jar is the vanilla server file)
    It appears that everything is working fine, but I know that is not normal. I have run servers for the personal use of friends and myself for several years, and this message hasn’t popped up before. Can you help me figure out how to fix this?

    1. The console being better looking may just be my opinion but the fact is it takes up less system memory than the GUI.

      Best way to find info on your issue is to search for the exception you’re getting. Generally at the top of the error output. Here we have “Not enough storage is available […]”. Sounds like your hard drive might be getting full. If not, it’s possible this is just a bug.

      If it’s not a full hard drive and the problem persists, try changing your setup. Maybe turn off the GUI or try a bukkit server.

  12. Now I’m a complete newbie at making batch files, but what I’ve been using up until now is :
    @echo off
    “C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe” -Xmx1024m -Xms1024m -d64 -jar “minecraft_server.jar”

    Problem is, the cmd window will stay up when it launches the server. What do I have to add to have it close automatically?

    1. Most of the time a command will run and then the window can be closed. However, your server needs to keep running for people to connect. The window must stay open until the server is shut down. Think of the cmd window as your server. Typing ‘stop’ will save and quit, causing the cmd window to close automatically.
      Also just an FYI, the @echo off isn’t really needed in this case. More of a personal preference thing. All it does is stop the cmd window from printing your command at the top of the window. It’ll scroll by and be gone so fast it doesn’t matter.

    1. Make sure that either your .jar file is named forge_server.jar or change the script to match the name of your .jar file.
      Also, the .jar file must be in the same folder as your .bat script. If you need the script to be somewhere else like on your desktop just make a shortcut to it.

        1. Hi Becky, Brandon has created a very good basic process for creating a basic .bat (batch) file for starting a Minecraft server. Go to the top of his article and read from top to bottom paying attention to the details. Remember a “bat file” is nothing more than an simple text file who’s file extension has been renamed from “.txt” to “.bat”. Here’s the link to the top of the article: http://www.brandonrubin.me/2013/10/07/minecraft-server-batch-file/

Leave a Reply