Java: Difference between revisions

From NixOS Wiki
imported>Mic92
remove out-of-place sentence
imported>Nornagon
Add more information about the various flavors of Java
Line 2: Line 2:


__TOC__
__TOC__
== JDK options ==
Your default choice should probably be to install <code>jdk11</code>, which is an alias for <code>openjdk11</code>. If you're in a server environment, go for <code>jdk11_headless</code>. Java 11 is the currently-maintained LTS version of OpenJDK as of Oct 2019.
As you might expect, though, many flavors of Java are available in NixOS.
* OpenJDK, by far the most popular non-Oracle JVM implementation
** <code>openjdk8[_headless]</code> for a legacy Java 8 VM required by some older apps
** <code>openjdk11[_headless]</code>, the currently-supported LTS version of OpenJDK
** <code>openjdk12[_headless]</code>, the current version of OpenJDK
* AdoptOpenJDK, prebuilt binaries for OpenJDK
** <code>adoptopenjdk-bin</code> points to the latest version of AdoptOpenJDK, which is version 11 at the time of writing.
** <code>adoptopenjdk-jre-bin</code> is available if you want to avoid downloading the compiler and only require the runtime environment.
* JetBrains JDK (<code>jetbrains.jdk</code>), a fork of OpenJDK with modifications made by JetBrains
* Oracle's JDK (<code>oraclejdk</code>), only version 8 is available.


== Using Oracle JDK instead of Open JDK ==
== Using Oracle JDK instead of Open JDK ==

Revision as of 02:28, 13 October 2019

This article is about Java, the programming language.

JDK options

Your default choice should probably be to install jdk11, which is an alias for openjdk11. If you're in a server environment, go for jdk11_headless. Java 11 is the currently-maintained LTS version of OpenJDK as of Oct 2019.

As you might expect, though, many flavors of Java are available in NixOS.

  • OpenJDK, by far the most popular non-Oracle JVM implementation
    • openjdk8[_headless] for a legacy Java 8 VM required by some older apps
    • openjdk11[_headless], the currently-supported LTS version of OpenJDK
    • openjdk12[_headless], the current version of OpenJDK
  • AdoptOpenJDK, prebuilt binaries for OpenJDK
    • adoptopenjdk-bin points to the latest version of AdoptOpenJDK, which is version 11 at the time of writing.
    • adoptopenjdk-jre-bin is available if you want to avoid downloading the compiler and only require the runtime environment.
  • JetBrains JDK (jetbrains.jdk), a fork of OpenJDK with modifications made by JetBrains
  • Oracle's JDK (oraclejdk), only version 8 is available.

Using Oracle JDK instead of Open JDK

Almost all Java packages in nixpkgs use Open JDK in form of a jre dependency. If you use Oracle JDK and also want other applications to use it, you can simply tweak your .nixpkgs/config.nix so that your desired application uses Oracles JDK or JRE.

Example with UMLet with JRE

{
  allowUnfree = true;
  packageOverrides = pkgs: rec {
    umlet = pkgs.umlet.override {
      jre = pkgs.oraclejre8;
    };
  };
}

Better font rendering

By default java does not enable antialiasing for font rendering. By exporting environment variables, this can be fixed:

$ export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd'

More options can be found in the archlinux wiki