Skip to content

Instantly share code, notes, and snippets.

@ChaosJohn
Forked from nathggns/freebsd-java.md
Created October 9, 2015 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaosJohn/4fb9bf135b0dcd7a91ea to your computer and use it in GitHub Desktop.
Save ChaosJohn/4fb9bf135b0dcd7a91ea to your computer and use it in GitHub Desktop.
Installing java on FreeBSD

Before installing this JRE, you have to install the linux binary compatibility on FreeBSD, you can follow this documentation. Jave requires some information about the proc. You have to mount linprocfs, type:

kldload linprocfs
mount -t linprocfs linprocfs /compat/linux/proc

and add this line to /etc/fstab:

linprocfs   /compat/linux/proc   linprocfs   rw   0  0

The Sun/Oracle JRE has a dependency marked as forbidden and the installation will fail. Go to /usr/ports/textproc/linux-f10-expat2.0.1/ and in the Makefile remove the line which starts with FORBIDDEN=. Next you have to manually get the linux tarball due to licence issue (like jre-7u65-linux-i586.tar.gz) from java official web site and copy the file to /usr/ports/distfiles. Then to install the JRE, go to /usr/ports/java/linux-sun-jre17/ and run:

make install distclean

Note: The previous version of this part, tested on FreeBSD 9.2 amd64, was explained like this: You may have to set JRE_UPDATE_VERSION variable in your Makefile to the actual number (e.g. 45 like in this example) and run make install NO_CHECKSUM=1.

Try running java -version. You may end up with a message that it can not find libjli.so. One way to fix it is to add your java paths to the search explicitly. Make a symlink:

ln -s /usr/local/linux-sun-jre1.7.0/lib/i386 /compat/linux/usr/lib/java

And in /compat/linux/etc/ld.so.conf.d/java.conf add:

/usr/lib/java
/usr/lib/java/jli

Run /compat/linux/sbin/ldconfig. Now java -version should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment