Fixing module {a} does not "opens {package}" to module {B} in Eclipse

Viewed 1377

The error module {a} does not "opens {package}" to module {B} has been asked before, where an explanation and solution was provided.

The solution was to add the following --add-opens VM argument to the command line when running the jar file like so: java -jar --add-opens=java.base/java.lang=ALL-UNNAMED some_jar_file.jar

I have a JavaFX program running Java-11.0.6 and javafx-sdk-14, built in Eclipse Version: 2019-09 R (4.13.0). When I export my project as a runnable jar file, the aforementioned fix works when I run the jar file from command prompt.

However, when I try to apply the VM argument fix to Eclipse so that I can run my program inside of Eclipse, I get the original module {a} does not "opens {package}" to module {B} error:

enter image description here

Am I misunderstanding the fix, using eclipse VM arguments incorrectly, or is it an issue with Eclipse? My company has the 2020-06 version of Eclipse that I could try, but since modules were introduce in Java9 years ago, I doubt it will help.

Note: I've made sure my Eclipse is configured to use Java 11 as its VM:

enter image description here

Edit 1: My command line from Eclipse is as follows: C:\Program Files\Java\jdk-11.0.6\bin\javaw.exe --add-opens=java.base/java.lang=ALL-UNNAMED -Dfile.encoding=Cp1252 -p "C:\Users\BL89306\eclipse-workspace\cto_emi_aat\bin;C:\Program Files\Java\javafx-sdk-14\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.graphics.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-14\lib\javafx-swt.jar;C:\Users\BL89306\eclipse-workspace\cto_emi_aat\lib\com.ibm.mq.allclient-9.2.0.1.jar;C:\Users\BL89306\eclipse-workspace\cto_emi_aat\lib\gson-2.8.6.jar;C:\Users\BL89306\eclipse-workspace\cto_emi_aat\lib\ikonli-javafx-11.3.5-sources.jar;C:\Users\BL89306\eclipse-workspace\cto_emi_aat\lib\ikonli-javafx-11.3.5.jar;C:\Program Files\Microsoft JDBC DRIVER 6.0 for SQL Server\sqljdbc_6.0\enu\jre8\sqljdbc42.jar;C:\Users\BL89306\eclipse-workspace\cto_emi_aat\lib\jaxb-api-2.3.1.jar" -m AAT/com.thehartford.aat.gui.AATApp

1 Answers

--add-opens=java.base/java.lang=ALL-UNNAMED opens the java.lang package of the java.base module to the ALL-UNNAMED module, which is everything on the classpath. But you have nothing on the classpath. If all your code is in the AAT module (where your class with the main method is), it's:

--add-opens=java.base/java.lang=AAT
Related