Java: Difference between revisions
update package sample links |
m update links |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
This article is about [ | This article is about [[Wikipedia:Java (programming language)|Java]], the programming language. | ||
__TOC__ | __TOC__ | ||
| Line 9: | Line 9: | ||
== JDK options == | == JDK options == | ||
Your default choice should probably be to install <code>jdk</code>, which is an alias to the latest [ | Your default choice should probably be to install <code>jdk</code>, which is an alias to the latest [[Wikipedia:Long-term support|LTS]]. If you're in a server environment, go for <code>jdk21_headless</code>. Java 21 is the currently-maintained LTS version of OpenJDK as of April 2024. | ||
As you might expect, though, many flavors of Java are available in NixOS. | As you might expect, though, many flavors of Java are available in NixOS. | ||
| Line 24: | Line 24: | ||
== VSCode + Language Support for Java (TM) by Red Hat extension == | == VSCode + Language Support for Java (TM) by Red Hat extension == | ||
Unfortunately the extension contains and uses a version of the JRE which makes use of dynamically loaded libraries, which nix cannot accomodate out-of-the-box. Fortunately there's a simple solution in the use of [https://github.com/ | Unfortunately the extension contains and uses a version of the JRE which makes use of dynamically loaded libraries, which nix cannot accomodate out-of-the-box. Fortunately there's a simple solution in the use of [https://github.com/nix-community/nix-ld nix-ld]. Here's a simple <code>flake.nix</code> snippet to get you started (I'll focus on the <code>devShell</code> part for brevity): | ||
<syntaxhighlight lang="nix" line highlight="6,10" copy> | <syntaxhighlight lang="nix" line highlight="6,10" copy> | ||
| Line 50: | Line 50: | ||
programs.vscode.userSettings = { | programs.vscode.userSettings = { | ||
"java.jdt.ls.java.home" = "${pkgs.jdk17}"; | "java.jdt.ls.java.home" = "${pkgs.jdk17}/lib/openjdk"; | ||
}; | }; | ||
</syntaxhighlight>Note that this will still result in the extension downloading its own JRE, it just will not be used. | </syntaxhighlight>Note that this will still result in the extension downloading its own JRE, it just will not be used. | ||
| Line 114: | Line 114: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
More options can be found in the [https://wiki.archlinux.org/ | More options can be found in the [https://wiki.archlinux.org/title/Java_Runtime_Environment_fonts ArchWiki] | ||
== Overriding java jks Certificate Store == | == Overriding java jks Certificate Store == | ||