Java: Difference between revisions
→VSCode + Language Support for Java (TM) by Red Hat extension: add highlights to the lines being described |
→VSCode + Language Support for Java (TM) by Red Hat extension: minor wording change |
||
| 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 flake.nix to get you started (I'll focus on the devShell part for brevity):<syntaxhighlight lang="nix" line highlight="6,10"> | 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 flake.nix to get you started (I'll focus on the devShell part for brevity): | ||
<syntaxhighlight lang="nix" line highlight="6,10" copy> | |||
devShell = pkgs.mkShell { | devShell = pkgs.mkShell { | ||
buildInputs = [ | buildInputs = [ | ||
| Line 37: | Line 39: | ||
# ^--- when using direnv, this line will require the 'use flake --impure' option. | # ^--- when using direnv, this line will require the 'use flake --impure' option. | ||
}; | }; | ||
</syntaxhighlight>The important lines are the two | </syntaxhighlight> | ||
The important lines above are the two starting with <code>NIX_LD...</code>. They will let nix-ld wrap the required, dynamically loaded libraries so that they are found when building the devShell. | |||
Another solution is to use the <code>[https://github.com/redhat-developer/vscode-java?tab=readme-ov-file#supported-vs-code-settings java.jdt.ls.java.home]</code> VSCode setting to point to a nix-built Java 17. For example, using home-manager's settings: <syntaxhighlight lang="nix"> | Another solution is to use the <code>[https://github.com/redhat-developer/vscode-java?tab=readme-ov-file#supported-vs-code-settings java.jdt.ls.java.home]</code> VSCode setting to point to a nix-built Java 17. For example, using home-manager's settings: <syntaxhighlight lang="nix"> | ||