java-language-server icon indicating copy to clipboard operation
java-language-server copied to clipboard

Module java.sql not found

Open mvsrgc opened this issue 2 years ago • 8 comments

I tried to install this language server using Mason with JDK 19. When I did this the link_linux.sh script failed with "module java.sql not found". I upgraded to JDK 20 and that fixed the problem.

https://www.oracle.com/java/technologies/javase/jdk20-archive-downloads.html

mvsrgc avatar Apr 14 '23 22:04 mvsrgc

Same problem happening for me but for JDK17

chkhetiani avatar Apr 18 '23 12:04 chkhetiani

Getting the same problem with OpenJDK 17 and OpenJDK 20, this is the error:

 Failed
    ◍ java-language-server
      ▼ Displaying full log
        Cloning into '.'...
        From https://github.com/georgewfraser/java-language-server
         * tag               v0.2.39    -> FETCH_HEAD
        + ./scripts/link_linux.sh
        Error: Module java.sql not found
        java.lang.module.FindException: Module java.sql not found
        	at java.base/java.lang.module.Resolver.findFail(Resolver.java:893)
        	at java.base/java.lang.module.Resolver.resolve(Resolver.java:129)
        	at java.base/java.lang.module.Configuration.resolve(Configuration.java:421)
        	at java.base/java.lang.module.Configuration.resolve(Configuration.java:255)
        	at jdk.jlink/jdk.tools.jlink.internal.Jlink$JlinkConfiguration.resolve(Jlink.java:217)
        	at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:536)
        	at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:424)
        	at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:276)
        	at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:55)
        	at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:33)
        spawn: bash failed with exit code 1 and signal 0. 

but the module seems to be there:

java --list-modules | grep java.sql@

[email protected]

fase29 avatar Apr 24 '23 08:04 fase29

I'm running the latest (java 20) and getting the same error.

IcePanorama avatar May 10 '23 19:05 IcePanorama

You have to install e.g. openjdk17-jmods (on Void Linux) or search for similar Java Modules package on your distribution.

friedelschoen avatar Jun 13 '23 17:06 friedelschoen

Can confirm installing jmods fixes the issue with JDK 20 as well.

MiranDaniel avatar Sep 03 '23 20:09 MiranDaniel

Can also confirm on Fedora 39, installing java-17-openjdk-jmods fixed the issue.

jazerix avatar May 21 '24 08:05 jazerix

I installed jmods for openjdk-latest, but that did not solve the issue. Installing jdk 17 + jmods did not solve the issue either. On Fedora 40 (Linux 6.9.5-200.fc40.x86_64) if that matters. Already have maven installed also.

IcePanorama avatar Jul 03 '24 15:07 IcePanorama

I installed jmods for openjdk-latest, but that did not solve the issue. Installing jdk 17 + jmods did not solve the issue either. On Fedora 40 (Linux 6.9.5-200.fc40.x86_64) if that matters. Already have maven installed also.

Check your JAVA_HOME is correct by cat link_linux.sh. If not, to find it by ls -l /usr/lib/jvm, and check if your java-xx... has jmods directory. If not, then install the corresponding jmods by sudo dnf install java-21-openjdk-jmods.

E.g.,

cat link_linux.sh 
#!/usr/bin/env bash
# Create self-contained copy of java in dist/linux

set -e

# Set env variables to build with mac toolchain but linux target
JAVA_HOME="/usr/lib/jvm/java-21-openjdk-21.0.4.0.7-2.fc40.x86_64"

# Build in dist/linux
rm -rf dist/linux
jlink \
  --module-path $JAVA_HOME/jmods \
  --add-modules java.base,java.compiler,java.logging,java.sql,java.xml,jdk.compiler,jdk.jdi,jdk.unsupported,jdk.zipfs \
  --output dist/linux \
  --no-header-files \
  --no-man-pages \
  --compress 2

ls -l /usr/lib/jvm/java-21-openjdk-21.0.4.0.7-2.fc40.x86_64/jmods

makamto avatar Oct 02 '24 07:10 makamto