Skip to content

Instantly share code, notes, and snippets.

@Martinfx
Forked from nathggns/freebsd-java.md
Created September 28, 2020 12:55
Show Gist options
  • Save Martinfx/a582e8ed380d8570aa5f10649b653548 to your computer and use it in GitHub Desktop.
Save Martinfx/a582e8ed380d8570aa5f10649b653548 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