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:
- (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 /usr/bin/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:
For 32-bit Linux:
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 LD_LIBRARY_PATH=/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64
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:
#!/bin/bash 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
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: https://help.ubuntu.com/community/EnvironmentVariables.
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