How to: Get Minecraft working in Linux

Minecraft Wallpaper

Attempt a quickfix?

If you’re trying to run Minecraft in Linux and it’s failing with errors like:

wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)


Could not find the main class: net.minecraft.Launcher.Frame

Then the chances are you can fix it up by performing the following actions:

  • Set your LD_LIBRARY_PATH variable with:
    export LD_LIBRARY_PATH="the-correct-path-to-your-JRE-java-binary-which-is-NOT-usr/bin"
  • (if needs be) Get rid of OpenJDK and install the official Sun/Oracle Java binaries if required.

Know how do all that? Awesome – carry on! Not so sure? Read on! ;-D

Setting the correct JRE location

First up, check if you have Java installed by typing java -version, if it comes up with something like the below, then you’re got Java installed, now we just need to find out where:

java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

If you didn’t get anything similar to the above you might want to install the official Oracle Java implementation, which I put together a brief step-by-step for here.

Assuming you have some variety of the Java Virtual Machine (JVM) install, check if your LD_LIBRARY_PATH environment variable is set with:

printenv | grep LIBRARY

If it comes up empty, then we need to find out where Java’s installed and set it correctly. To get the correct path for where your particular Java install is located, you might be tempted to try running which java:

$ which java

However, this is a little bit of a fib, as Java is part of the alternatives setup where we can have multiple versions installed at once – which means that /usr/bin/java is really a symbolic link to the true java location. To find where it’s really pointing we can either ask update-alternatives how it’s configured like so (and pick a version different version if we want to):

$ update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                               Priority   Status
  0            /usr/bin/gij-4.6                    1046      auto mode
  1            /usr/bin/gij-4.6                    1046      manual mode
* 2            /usr/lib/jvm/jdk1.7.0_07/bin/java   1         manual mode
Press enter to keep the current choice[*], or type selection number: 2

Or we can look closely at the /usr/bin/java symlink:

$ ls -alh /usr/bin/java
lrwxrwxrwx 1 root root 22 Aug 15 05:03 /usr/bin/java -> /etc/alternatives/java

Which if we then look closely at /etc/alternatives/java then points at:

ls -alh /etc/alternatives/java
lrwxrwxrwx 1 root root 33 Aug 15 16:37 /etc/alternatives/java -> /usr/lib/jvm/jdk1.7.0_07/bin/java

Same thing as what the alternatives config’s pointing at ;-)

Now that we have the correct path, we can set it in the following manner (remember to substitute your particular Java location into the below lines!):

For 64-bit Linux:

export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64"

For 32-bit Linux:

export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/i386"

With that done, you should be able to see that it’s set by running:

printenv | grep LIBRARY

Which should give you something like:

$ printenv | grep LIBRARY

Finally, we should be fit to launch Minecraft like this (assuming the minecraft.jar file is in your home folder):

java -Xmx1024M -Xms512M -cp ~/minecraft.jar net.minecraft.LauncherFrame

Or, without setting the memory and classpath variables, like this:

java -jar ~/minecraft.jar

Be aware that the LD_LIBRARY path will only be set for the current session of the current shell, so you’ll have to re-set it a lot. A quick and easy way to do this is to just knock together a quick launcher script as below (substituting your paths in) and throw it in /usr/local/bin:

export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64"
java -Xmx1024M -Xms512M -cp ~/Games/Minecraft/minecraft.jar net.minecraft.LauncherFrame

Final Notes

Not being able to set a persistent LD_LIBRARY_PATH is a pain, because it won’t take if set in the ~/.profile or ~/.bash_profile or ~/.bash_rc config files (I’m not so sure about ~/.pam_environment) – which you can read about here:

There’s a fix which involves disabling ssh-agent in this bug report (see post #21 here), but really for the sake of a two line launcher script I think it’s best to just leave it be.

Happy mining and crafting! =D

9 thoughts on “How to: Get Minecraft working in Linux”

    1. Not really – I was just playing around with it to see what all the fuss is about, and then got narked that it wouldn’t play ball – so I fixed it and wrote it up!

      1. Sweet, If you can’t tell already I am addicted. I bought it for $5 AUD when it was in Alpha. I watched minceraft go from a few hills to added weather or mobs etc.. Once it went into Beta it was $15 AUD and now full release is $30 AUD.
        I spend most of my down time on my public Minecraft server with friends.

        1. Cool – and yeah, I bought a copy for Loki for 1200 XBox points or something the other day, so it’s not the cheapest thing. Tho I did get my Android copy for 10 cents when it was on offer in the “1 billion app downloads” promotions =D

Leave a Reply

Your email address will not be published.

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