Java
Catalog v8.
Installs a headless OpenJDK and the jdtls language server.
Select
[toolchains]
java = "21"Choose the line in the [toolchains] table of limanix.toml and apply the change. Add Maven or Gradle in the same table to build projects.
Versions
| Value | JDK | Notes |
|---|---|---|
25 | OpenJDK 25.x | |
21 | OpenJDK 21.x | Recommended |
17 | OpenJDK 17.x |
Lines come from the base Nixpkgs revision and receive its updates with each catalog release. The JDK is headless: it leaves out the graphical libraries, which a VM without a display does not use.
Use
Inside the VM, compile and run a class:
javac Main.java
java MainRun jshell to try code interactively. JAVA_HOME points to the selected JDK in every session.
Other tools and JDKs
The selected JDK is also at /usr/lib/jvm/openjdk-<line>, where Gradle, IntelliJ IDEA and VS Code look for installed JDKs. When a project asks for another Java version, Gradle or the IDE downloads a generic Linux JDK, which runs with nix-ld, on in every LimaNix VM.
Editor support
The module installs jdtls for editors that support the Language Server Protocol; AstroNvim starts it for Java files. jdtls runs on its own JDK from Nixpkgs, independent of the selected line, and loads Lombok: the editor understands code that uses Lombok annotations.
Configuration and integration
| Boundary | Contract |
|---|---|
| Public capability | lmx.capabilities.jdk.package, the newest selected JDK; lmx.capabilities.languageSupport.tools.jdtls; Java parser |
| Settings | JAVA_HOME; /usr/lib/jvm/openjdk-<line> for every selected line |
| Integration | Maven, Gradle and Quarkus run on the JDK of the capability |
| Services | No daemon |
Corner cases
| Case | Behavior or next step |
|---|---|
| A downloaded JDK does not start | Check that programs.nix-ld.enable is on, or select that Java line |
| A desktop Java program needs a display | The headless JDK cannot open windows; run the program on the Mac |
