Note: This tutorial assumes you have basic knowledge of how to use pkgsrc, and have it and a full base system of NetBSD installed. If you don’t know how to use pkgsrc, read up more here.
Minecraft is written in Java, so porting it across systems is a non issue, right? That is mostly true — except that the LWJGL library it makes use of is platform dependent. Trying to boot up minecraft on NetBSD using the standard OpenJDK that ships with pkgin/pkgsrc results in this tidy error:
Exception in thread "main" java.lang.LinkageError: Unknown platform: NetBSD
The solution to this is to use NetBSD’s Linux emulation to run LWJGL, which is done by using Oracle’s Linux JRE rather than pkgsrc’s OpenJDK. This method was tested and working on NetBSD 7 + pkgsrc stable/Q2_2016, but should work on any recent NetBSD release. If you need a different Oracle binary, pkgsrc will tell you which you need; just run ‘make’ and it will spit it out when it fails:
- Download the Oracle JRE Binaries:
curl -L -k -b "oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jre-8u92-linux-x64.tar.gz > jre-8u92-linux-x64.tar.gz
- Accept the Oracle Licence:
echo "ACCEPTABLE_LICENSES+= oracle-binary-code-license" >> /etc/mk.conf
- Build and install oracle8-jre
make && make install
- Enable Linux Emulation layer
echo "procfs /emul/linux/proc procfs rw,linux" >> /etc/fstab
- Download Linux version of minecraft, and run!
And there you have it:
One interesting thing to note is that this doesn’t just apply to amd64 archetecture; if you have an x86 (32 bit) processor, you can substitute Oracle’s i586-compiled JRE and Linux emulation will still work. Taking that one step further, if you run sparc or sparc64 processors, you can use NetBSD Solaris emulation, and run LWJGL Solaris-compiled binaries with the Oracle sparc/sparc64 JRE!