Friday, August 3, 2012

How To Create a Minecraft Desktop Launcher in Unity (Ubuntu 12.04)

I had recently decided to install and play minecraft on my desktop running Ubuntu 12.04, and after a couple of times got sick of having to open it up from the terminal all the time - so I decided to make a desktop shortcut. I figured I would post how I did this to save others some time. This should also allow for the easy creation of desktop shortcuts for other programs as well.

To make this work make sure that you know where the minecraft.jar file is and download an image for the desktop icon. (You can download the jar at http://www.minecraft.net/download. I used the icon at the following link http://fav.me/d36xhh8)

The first thing you need to do is create a .desktop file on your desktop. Copy/paste the following into your favorite text editor:

[Desktop Entry]
Name=Minecraft
GenericName=mcLaunch
Comment=Launches Minecraft
Type=Application
Exec=java -jar <Directory>/minecraft.jar -Xms 4096M
Icon=<Directory>/minecraftIcon.png
Terminal=false
Categories=Game;
Name[en_US]=Minecraft

for a full explanation of what all this does see Anatomy of a .desktop File.
Make sure to replace the bolded values with the appropriate directory (in place of directory) and memory allocation (in place of 4096M - 4 GB of RAM dedicated). Furthermore, if your image name is different make sure to replace it.

Save this file in your ~/Desktop/ directory with the filename Minecraft.desktop

The next thing you need to do is make sure that the file is executable. The easiest way to do this is right click on the desktop icon, select properties -> Permissions and fill in the box next to "Allow executing file as program". Alternatively, open up a terminal, cd into the Desktop directory, and type the following comand:
sudo chmod +x Minecraft.desktop

When you do this the icon you selected should be visible on your desktop, and double clicking it will launch minecraft.