Using a script to update the Minecraft server.jar

Share this:

As I was looking for an easier way to download and update the Minecraft server.jar, I stumbled upon some scripts that pointed me to this version_manifest.json file that contains all the available versions of Minecraft.

While this json file does not contain the direct download URLs of the binaries, it provides the url with all the details of each of the versions. The version’s json file instead is where you would find the download URL. The combination both of these json files makes it possible to programmatically download the latest release of Minecraft’s server.jar using a script.

Scripting the script on macOS Catalina

I run the Minecraft server on my MacBook that’s currently running on macOS Catalina. As the default shell is now on zsh, I figured that I should try and write my own script from scratch and see how different zsh was from bash.

And thus this script (link) here that I’ve uploaded to my git lab repository here.

The Minecraft script

I’ve written this Minecraft server update script on my macOS Catalina, and thus have tested it to work on macOS. However, the commands used are not specific to macOS and therefore should work on Linux OS as well.

I’ve also assumed that wget and jq is already installed on your desktop or notebook.

  • wget – a great utility to download files for a URL
  • jq – a nifty JSON query utility to read values from a JSON file.

For macOS users, I recommend using Homebrew to install both wget and jq if you don’t already have them. Instructions on installing Homebrew can be found at at this link. Once installed, run the follwing command to install both wget and jq.

brew install jq wget

As for linux users, most of probably already have both jq and wget. Otherwise, just use the apt, yum or apk package manager on your OS and install them. I should not need to tell you how to do it. 😉

Using the Minecraft script

If you’ve not already downloaded the script, get it here at this link:

Using the script is rather simple. Just download and move the to the same directory where your Minecraft server.jar file is located. Then set the permissions for the script file to be executable.

chmod +x

Then just run the script.


Fun fact: I’ve just tested this script on my iPad Pro using the iSH terminal app. It runs perfectly as well!

Some points to note

On the first run, the script will initialise itself by creating a current_ver.txt file and a backups directory if they are not found. It will then also proceed to download the current release of server.jar and move your existing copy to the backups directory as server_0.jar. This is because the script does not already have a reference of the exsiting version which is what the current_ver.txt files is for.

If you do not want the script to unnecessarily download the same version, then manually create a current_ver.txt file with the existing version in the file.

An example of a command you can use to do that is as the following:

echo 1.15.1 > current_ver.txt

What the script is actually does

I’ve commented the script file to be descriptive so you can actually read through what it does step by step. But allow me to lay it out here as an overview as well.

  1. Check for a current_ver.txt file and a backups directory and initialises them if they are not found.
  2. Read the current_ver.txt to get the current server.jar‘s version.
  3. Download the version_manifest.json and get the latest release version number.
  4. Compare the current and latest versions and proceed with the rest of the script it the versions don’t match.
  5. Get the URL of the latest release version’s json file and download the version’s json file.
  6. With the version’s json file, Get the download URL of the latest release server,jar.
  7. Move the current server.jar to the backups directory with a server_<current_version>.jar name.
  8. Download the latest server.jar.
  9. Update the current_ver.txt with the latest verison number.
  10. Finally, clean up all the json files.

Again, you can find my GitLab repository link here: Please feel free to clone it, fork it and do whatever you might want with it. Better yet, improve it and let me know what else I’ve yet to learn on zsh scripting.

Share this:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.