Java: Difference between revisions

Kvtb (talk | contribs)
JavaFX/Webkit
DHCP (talk | contribs)
m update links
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This article is about [https://en.wikipedia.org/wiki/Java_(programming_language) Java], the programming language.
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 [https://en.wikipedia.org/wiki/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.
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/Mic92/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):
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/index.php/Java_Runtime_Environment_fonts archlinux wiki]
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 ==
Line 151: Line 151:
=== jdk11 ===
=== jdk11 ===


JDK11 does not provide the cacert overridable and therefore it is not possible to use the same technique to override the truststore.
JDK11 does not provide the cacert overridable and therefore it is not possible to use the same technique to override the truststore.
 
As an alternative solution you can either set an environment variable, <code>JAVAX_NET_SSL_TRUSTSTORE</code>, or pass an argument to your program, <code>-Djavax.net.ssl.trustStore</code>, with the location of your cacert. See [https://discourse.nixos.org/t/custom-ssl-certificates-for-jdk/18297/9 discussion].


== Building and Packaging ==
== Building and Packaging ==
Line 179: Line 181:
==== Ivy ====
==== Ivy ====


[https://ant.apache.org/ivy/ Ivy] is a package manager for Ant, not to be confused with [https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/ivy/default.nix ivy] - an APL-like calculator
[https://ant.apache.org/ivy/ Ivy] is a package manager for Ant, not to be confused with [https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/iv/ivy/package.nix ivy] - an APL-like calculator


To fetch ivy sources manually, see for example [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/jedit pkgs/applications/editors/jedit]
To fetch ivy sources manually, see for example [https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/je/jedit/package.nix pkgs/applications/editors/jedit]


To fetch ivy sources in a fixed-output-derivation, see for example [https://github.com/milahu/nur-packages/blob/master/pkgs/yacy/yacy.nix yacy.nix]
To fetch ivy sources in a fixed-output-derivation, see for example [https://github.com/milahu/nur-packages/blob/master/pkgs/yacy/yacy.nix yacy.nix]
Line 203: Line 205:
{{Nixpkgs manual|sec-language-java}}<br /><br /><br /><br /><br />{{Wikipedia|Java_(programming_language)}}
{{Nixpkgs manual|sec-language-java}}<br /><br /><br /><br /><br />{{Wikipedia|Java_(programming_language)}}


[[Category:Applications]]
[[Category:Languages]]
[[Category:Languages]]