Reputation: 33
I am programming my fisrt JavaFX v17.0 project using Maven under Intellij. Everything was fine, I was able to create a JavaFX view-controller and to display it. But the problem came when I added these lines to the module-info :
requires Rserve;
requires REngine;
Which corresponds to those dependencies in the pom.xml:
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/Rserve -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>Rserve</artifactId>
<version>1.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/REngine -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>REngine</artifactId>
<version>2.1.0</version>
</dependency>
When I compile, I get these errors :
...
Checking sources
Copying resources... [first-javafx-try]
Parsing java... [first-javafx-try]
java: the unnamed module reads package java.io from both api.classic and java.base
java: the unnamed module reads package java.lang from both api.classic and java.base
java: module api.classic reads package java.lang from both java.base and api.classic
java: module api.classic reads package java.io from both java.base and api.classic
java: module REngine reads package java.lang from both java.base and api.classic
java: module REngine reads package java.io from both java.base and api.classic
java: module Rserve reads package java.lang from both java.base and api.classic
java: module Rserve reads package java.io from both java.base and api.classic
Checking dependencies... [first-javafx-try]
...
I tried adding these lines to the vm configuration :
--add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED
But it still doesn't work.
Could you provide some explanation about the source of the errors and a way to solve them please ?
In fact, the dependencies RServe and REngine are not modularized, but I don't know how to deal with that.
For more information, here is the full 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.example</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>
<name>demo</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.7.1</junit.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/Rserve -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>Rserve</artifactId>
<version>1.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/REngine -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>REngine</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17-ea+11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17-ea+11</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.0</version>
</dependency>
<dependency>
<groupId>com.dlsc.formsfx</groupId>
<artifactId>formsfx-core</artifactId>
<version>11.3.2</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.4.0</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>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.demo/root.circlepong.CirclePongApp</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And the module-info :
module root {
requires javafx.controls;
requires javafx.fxml;
requires Rserve;
requires REngine;
opens root.circlepong to javafx.fxml;
exports root.circlepong;
opens root.switchscene to javafx.fxml;
exports root.switchscene;
opens root.mvvmfxFirsttry to javafx.fxml;
exports root.mvvmfxFirsttry;
}
When running the compile command, I found out that Intellij runs the command :
C:\Users\Thibault\.jdks\openjdk-17.0.1\bin\java.exe "-javaagent:D:\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=52247:D:\IntelliJ IDEA 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\Programmation\MASI1.5\CarteAPuce\JavaCardsTools\lib\api_classic-3.1.0.jar;D:\JavaProg\MASI_Projet_Integre\mavenJava11Project\target\classes;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx-swt.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.web.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.base.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.fxml.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.media.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.swing.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.controls.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.graphics.jar;C:\Users\Thibault\.m2\repository\org\rosuda\REngine\Rserve\1.8.1\Rserve-1.8.1.jar;C:\Users\Thibault\.m2\repository\org\rosuda\REngine\REngine\2.1.0\REngine-2.1.0.jar" root.switchscene.SwitchSceneApp --module-path C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib --add-modules javafx.controls,javafx.fxml
Here we can see that there is the jar 'api_classic-3.1.0.jar' in the classpath but I never specified it, how can I remove that from the automatic command ?
Upvotes: 1
Views: 382
Reputation: 33
I found out that the problems come from the 'D:\Programmation\MASI1.5\CarteAPuce\JavaCardsTools\lib\api_classic-3.1.0.jar' jar added. As I was not able to remove theline from the Intellij automatic command, I deleted the jar and now everything works fine. This is probably not the best way to do it, but it works.
Upvotes: 1