How to install specific Oracle JDK version


I’d like to run IBKR TWS (trading software) which requires a specific version of Oracle JRE/JDK - currently 8u202.

How would one create an overlay that creates a new package for JDK 8u202. I have the correct .tar.gz.

I’ve found pkgs/development/compilers/oraclejdk/jdk-linux-base.nix, which seems like exactly what I want but I don’t know if/how to use it from inside an overlay. How can I do that, or maybe there’s a better way?

Right, I can simply copy jdk-linux-base.nix into the overlay. That works :slight_smile:

Still, maybe there’s a better way?

Subscribing on this. The current workflow (sign up on Oracle website, manual downloads, manual nix commands) is pretty tedious and I’ve ended up using a virtual machine with a different OS to run TWS.

@supermarin I found legacyPackages.x86_64-linux.ib-tws is already in nixpkgs. You may wan to to try that.

Alternatively if you want the self-update feature to work, which myself I do want, you can do the following.

Add an overlay in configuration.nix:

nixpkgs.overlays = [
  (self: super: {
      oraclejdk8-202 = ((self.callPackage (import /path/to/jdk8-linux-202.nix)) { installjdk = true; pluginSupport = false; });

Where jdk8-linux-202.nix is:

import ./jdk-linux-base.nix {
  productVersion = "8";
  patchVersion = "202";
  sha256.i686-linux = "/yEY5O6MYNyjS5YSGZtgjjj8th6jHQLNvI9tNPIh3+0=";
  sha256.x86_64-linux = "1q4l8pymjvsvxfwaw0rdcnhryh1la2bvg5f4d4my41ka390k4p4s";
  sha256.armv7l-linux = "oXbW8hZxesDqwV79ANjjjdnS71O51ZApKbQhqq4i/EM=";
  sha256.aarch64-linux = "oFH3TeIzVsFk6IZcDjjjDVJC7dSbGcwhdUH/WUXSNDM=";
  jceName = "";
  sha256JCE = "19n5wadargg3v8x76r7ayag6p2xz1bwhrgdzjs9f4i6fvxz9jr4w";

And jdk-linux-base.nix is copied verbatim from nixpkgs. Then you start TWS like so:


export INSTALL4J_JAVA_HOME=/nix/store/2kqmccic38hc2rf9s9jchs00gfr67wcw-oraclejdk-8u202
cd ~/Jts
exec ./tws

It’s a little bit uh-oh to set up, hence my question about a better way, but it works.

As to downloading JRE/JDK, well… Oracle :man_shrugging:, is all I’m going to say :wink: