Linux – Not Found Error : Module java. base, required when trying jlink on Fedora

Not Found Error : Module java. base, required when trying jlink on Fedora… here is a solution to the problem.

Not Found Error : Module java. base, required when trying jlink on Fedora

When trying to use jlink on Fedora with this plugin, https://github.com/openjfx/javafx-maven-plugin

<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.alcamech</groupId>
    <artifactId>jomo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>jomo</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
    </properties>

<dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>17.0.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17.0.0.1</version>
        </dependency>

<dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <compress>2</compress>
                            <noHeaderFiles>true</noHeaderFiles>
                            <stripDebug>true</stripDebug>
                            <noManPages>true</noManPages>
                            <launcher>jomo</launcher>
                            <mainClass>com.alcamech.jomo/com.alcamech.jomo.Jomo</mainClass>
                            <jlinkImageName>jomo</jlinkImageName>
                            <jlinkZipName>jomo</jlinkZipName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Module information .java

module com.alcamech.jomo {
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.media;

opens com.alcamech.jomo to javafx.fxml;
    exports com.alcamech.jomo;
}

I get the following error
Error: The module java.base required by com.alcamech.jomo could not be found

Run java --list-modules to return.

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

Current

Fedora release 35 (Thirty Five), 5.15.13-200.fc35.x86_64

openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment 18.9 (build 11.0.13+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8, mixed mode, sharing)

I’m following the https://openjfx.io/openjfx-docs/ The sample projects in (Modular Intellij, Modular CLI) encountered this error. Clone my project repo on Windows and run the jlink command successfully. I tried the jlink command via CLI on linux and got the same error. I opened a GitHub issue with full maven logs here https://github.com/openjfx/javafx-maven-plugin/issues/146

Debug jlink command line from MVN javafx:link output

[DEBUG] Executing command line: [/usr/lib/jvm/java-11-openjdk/bin/jlink, --module-path, /home/alcamech/Development/jomo/target/classes:/home/alcamech/.m2/ repository/org/openjfx/javafx-base/17.0.0.1/javafx-base-17.0.0.1-linux.jar:/home/alcamech/.m2/repository/org/openjfx/javafx-controls/17.0.0.1/ javafx-controls-17.0.0.1-linux.jar:/home/alcamech/.m2/repository/org/openjfx/javafx-fxml/17.0.0.1/javafx-fxml-17.0.0.1-linux.jar:/home/alcamech/.m2/repository/org/ openjfx/javafx-graphics/17.0.0.1/javafx-graphics-17.0.0.1-linux.jar:/home/alcamech/.m2/repository/org/openjfx/javafx-media/17.0.0.1/javafx-media-17.0.0.1-linux.jar, -- add-modules, com.alcamech.jomo, --output, /home/alcamech/Development/jomo/target/image, --compress, 0]

Solution

I’m missing the jmods directory in my jdk. On Fedora, jmods are installed separately
https://fedora.pkgs.org/35/fedora-x86_64/java-11-openjdk-jmods-11.0.12.0.7-4.fc35.x86_64.rpm.html

Run sudo dnf install java-11-openjdk-jmods

Related Problems and Solutions