1

IDE: IntelliJ. Trying to use JavaFX for the first time with some additional libraries, and with an installable package - (c/o JLink/JPackage) Have followed directions from OpenJFX for a Modular Project from IDE and can get this to work no problem. https://openjfx.io/openjfx-docs/

Adding libraries though I am just getting this error: "Error occurred during initialization of boot layer java.lang.module.FindException: Module eu.hansolo.medusa not found, required by ModuleName"

Have read a number of similar threads on this error but no joy here specifically.

Have tried adding adding to VM on run configuration ie:
--module-path ${PATH_TO_FX}:mods/production --add-modules javafx.controls,javafx.fxml,eu.hansolo.medusa -
still getting "Error occurred during initialization of boot layer java.lang.module.FindException: Module eu.hansolo.medusa not found"

However.. If I delete the "module-info.java" file.. I can run the application in IntelliJ no problem.. however.. I then can't use JLink to make the custom runtime image.

Any advice or pointers to reading I can do would be greatly appreciated and many thanks in advance.

  • Heya Matt appreciate the response - the module will run fine and I can then use JPackage to make a custom runtime and installer. Once I add the Medusa library.. It won't find it.. I have Medusa added in module-info.java ie:module hitSongDNA { requires javafx.controls; requires javafx.fxml; requires eu.hansolo.medusa; opens org.openjfx to javafx.fxml; exports org.openjfx; } - but won't find it when running – pauliamgiant Jun 02 '20 at 09:10
  • I'm still a bit confused. Is your error happening while trying to run your project in intellij? How did you add the Medusa library to your project? In your vm parameters option `--module-path ${PATH_TO_FX}:mods/production` does mods/production include Medusa jmod files? – matt Jun 02 '20 at 09:19
  • Yes the error is happening when I try to run in intelliJ. I added Medusa as a jar file from maven repo using Project-Structure - >Libraries -> From Maven . Ok mods/production doesnt include Medusa jmod files.. indicatiing im missing something here.. I've set this up using the guide from https://openjfx.io/openjfx-docs/ so the inclusion of JMods has come from there and something I'm not sure on. Appreciated! – pauliamgiant Jun 02 '20 at 09:32
  • Version is 2020.1.1 Ultimate.. I've only just started using that in the last month.. loving it tho. Prior to that NetBeans. – pauliamgiant Jun 02 '20 at 09:47
  • 1
    Matt I just dragged the Medusa Jar file into mods/production and that is now working both when I run in InteliJ and also when I use JPackage to make installable file. Potententially not the most elegant way of managing the library? but its working and very grateful for your input. – pauliamgiant Jun 02 '20 at 09:54

1 Answers1

1

So the issue appears to be that you haven't added Medusa to your module path. The way I accomplished this is by using maven.

I added the dependencies to my pom file and created a module-info.java and everything seemed to work.

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <groupId>org.example</groupId>
    <artifactId>MavenFxied</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>14.0.1</version>
        </dependency>
        <dependency>
            <groupId>eu.hansolo</groupId>
            <artifactId>Medusa</artifactId>
            <version>11.5</version>
        </dependency>
    </dependencies>

</project>

module-info.java

module mavenfxied {
    requires javafx.controls;
    requires eu.hansolo.medusa;
    exports example;
}

I made an example class to test it out.

Main.java

package example;

import eu.hansolo.medusa.Gauge;
import eu.hansolo.medusa.GaugeBuilder;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

    public void start(Stage stage) throws Exception {
        StackPane pane = new StackPane();
        Gauge g = GaugeBuilder.create()
                .skinType(Gauge.SkinType.SPACE_X)
                .animated(true)
                .decimals(0)
                .title("SpaceX")
                .unit("km/h")
                .maxValue(30000)
                .threshold(25000)
                .build();
        pane.getChildren().add(g);
        Scene scene = new Scene(pane);
        stage.setScene(scene);
        stage.show();
    }
}

If you aren't using maven, then the solution proposed in the comments of adding the jar file to a location on the module-path might be the only way.

matt
  • 10,892
  • 3
  • 22
  • 34