↓ Skip to main content

Installing Oracle JDK 8 in Gentoo without icedtea

·295 words·2 mins
Sergii Zolotarov
Author
Sergii Zolotarov
Twenty years of Java, from Kyiv to Leeuwarden. Currently at Booking.com

An attempt to install Oracle JDK in Gentoo leads to mandatory installation of a ice tea cup (icedtea-bin +90mb of redundant binaries). This sort of contradicts the concept of a lightweight distro, right?

I suspect that this is just a dependency bug since icedtea is mandatory for the java-config (which manages which java is active on your system). And you cannot go without it. Almost. Having googled a bit I found a nice solution:


# pull in the config package without dependencies
emerge -1 --nodeps app-admin/eselect-java 
# next goes the thing that pulls the package
emerge -av --tree oracle-jdk-bin:1.8

It will swear you have to accept some licenses, download stuff manually etc, do what it asks. JDK and JCE policy (if you need it), download manually and put to /usr/portage/distfiles.

Licences I accept manually, who reads them anyway?


echo 'ACCEPT_LICENSE="*"' >> /etc/portage/make.conf
echo "=dev-java/oracle-jdk-bin-1.8.0.25 ~amd64" >> /etc/portage/package.accept_keywords

If the installer complains that it cannot unpack the tars, do not forget to let portage access the files:


chown -R portage:portage /usr/portage/distfiles/jce_policy-8.zip 
chown -R portage:portage /usr/portage/distfiles/jdk-8u25-linux-x64.tar.gz

Now let’s check whether we have it installed:


eselect java-vm list

Available Java Virtual Machines:
  [1]   oracle-jdk-bin-1.8  system-vm

That’s it.

Well, not quite :) If you later try to emerge @world the package eselect-java will definitely try to restore justice by sucking in the icedtea to satisfy its dependencies. In order to overcome this let’s change some files.

Mask icedtea


# /etc/portage/package.mask

dev-java/icedtea-bin
dev-java/icedtea-web

Change the versions of virtual packages accepted from 1.6 to 1.8 (these are not stable package as of time of this writing):


# /etc/portage/package.unmask

>=virtual/jdk-1.8
>=virtual/jre-1.8

And finally we need to accept new keywords (for my system its ~amd64):


# /etc/portage/package.accept_keywords

>=virtual/jdk-1.8.0 ~amd64
>=virtual/jre-1.8.0 ~amd64

Now that’s it.


First published on the old anydoby.com blog on 2014-12-31.