Thursday, January 17, 2013

Installing Minecraft on Ubuntu

UPDATE: As of Minecraft 1.6 these instructions no longer work. I have posted updated instructions at Installing Minecraft 1.6 on Ubuntu.

This post is for anyone who wants to install Minecraft on Ubuntu and have it feel like any other game installed via the Ubuntu Software Center. It assumes you have already purchased Minecraft and provides full Unity integration, though Unity is not needed for this to work. In fact, I suspect it should work for any Linux distribution that has a desktop environment.

We are going to do this via the command-line because copy-and-pasting commands from this tutorial is easier and more fool-proof than following a long list of screen shots. It's also easier for me to write it that way as there are fewer steps.

First we need to install Java. The website claims it needs Sun Java, but the open source Java in the Ubuntu repos works just fine in my experience.
sudo apt-get install openjdk-7-jre
Now we need the actual game
sudo wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft.jar -o /usr/games/minecraft.jar
sudo chown root:games /usr/games/minecraft.jar
sudo chmod 755 /usr/games/minecraft.jar
Change the vi part in the next section to gedit if you want a graphical text editor.
sudo vi /usr/games/minecraft
The file contents should be as follows.
java -Xmx1024M -Xms512M -cp /usr/games/minecraft.jar net.minecraft.LauncherFrame
And then set the proper permissions on the file
sudo chown root:games /usr/games/minecraft
sudo chmod 755 minecraft
Again, change vi with something else if that is easier for you.
sudo vi /usr/share/applications/minecraft.desktop
And put this in the file.
[Desktop Entry]
Name=Minecraft
Comment=Build your own world
Exec=minecraft
Icon=minecraft
Terminal=false
Type=Application
Categories=GNOME;Applications;Game
Keywords=minecraft;Game
StartupNotify=true
The last piece we need is an icon. There are many good Minecraft icons at http://www.rw-designer.com/icon-detail/5547 I like http://www.rw-designer.com/icon-image/5547-256x256x32.png as it gives us the highest resolution available. Replace the URL of the icon you prefer to use in the following command.
sudo wget http://www.rw-designer.com/icon-image/5547-256x256x32.png -o /usr/share/pixmaps/minecraft.png
Now you should be able to play Minecraft by simply typing minecraft in the command-line, in the Unity dash, the KDE prompt, or by browsing to the games menu in the applications menu in your desktop environment of choice. It is also available to all users of your desktop.

You also do not need to do anything to update. Minecraft updates itself each time you start it.

BONUS

I've got one more neat trick up my sleeve. If a CraftBuntu spin sounds good to you, here's how you can setup Ubuntu to just run Minecraft when you sign in. It assumes you have already done the above.
sudo cp /usr/share/applications/minecraft.desktop /usr/share/xsessions/
Now Minecraft is an available option when you select your desktop environment. This works best if you set Fullscreen in the Minecraft options.

You could do a number of things with this setup. You could setup a minimal Ubuntu installation that has no desktop environment, or other desktop-related software installed. You could also allow guests to play Minecraft without touching any of your stuff by them selecting the Ubuntu guest account and setting Minecraft for the login. I have even found that on my struggling laptop this setup allows Minecraft to run more smoothly as there is no other desktop cruft running in the background.