I have just updated my eclipse project from java 8 to java 11. But I am using external libraries in this project that were designed for java 8. I have successfully imported these libs into projects classpath as it used to be but eclipse just refuses to use them. When I try to import them it will highlight it as an error with a message "The type bla.bla.Foo is not accessible". I also tried to import these libs into projects modulepath and requires them in module-info.java which solves the problem in some way but I still keep receiving warning "Name of automatic module 'SomeLib' is unstable, it is derived from the module's file name." and "The type Foo from module SomeLib may not be accessible to clients due to missing 'requires transitive'" always when I try to use an object from these libs.
Note: I am using OpenJDK 11 with JavaFX 11.
Note: Libs that I am trying to import are https://github.com/PetoPetko/JavaFx-Image-Animation
Note: I'm also getting "The type com.sun... is not accessible" also on everything that is from com.sun... package but I'm not sure if this is related to this problem.

- 31
- 1
- 6
-
Delete your `module-info.java` file in the default package or learn about [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System). – howlger Sep 13 '20 at 09:06
-
@howlger JavaFx will not work if I remove module-info because JavaFx is for java 11 – Programer001 Sep 13 '20 at 19:31
-
`module-info.java` is optional, also for JavaFX (see [documentation for non-modular](https://openjfx.io/openjfx-docs/#IDE-Eclipse)). Java 11 does not require to have a `module-info.java` file. A class is not accessible if you have `module-info.java` file without the corresponding `requires` statement or if it's in a package of a module that does not export this package. – howlger Sep 13 '20 at 22:22
-
@howlger I tried the stuff you have mentioned and it actually solves in program errors! However when I try to run the application of course with `--module-path "C:\Program Files\JavaFx\lib" --add-modules javafx.controls,javafx.fxml` as VM argument it will throws `java.lang.IllegalAccessError: superclass access check failed: class ugp.org.Texture.Texture$1 (in unnamed module @0x7dc46891) cannot access class com.sun.javafx.collections.ObservableListWrapper (in module javafx.base) because module javafx.base does not export com.sun.javafx.collections to unnamed module @0x7dc46891` – Programer001 Sep 14 '20 at 08:51
-
It looks like everything from com.sun.javafx is a problem from some reason! I also realized that tutorial you have sent is about java12+ and javafx12+. Could updating from OpenJDK and JavaFX 11 to OpenJDK and JavaFX 12 solve this problem? – Programer001 Sep 14 '20 at 08:57
-
1Please follow the documentation: [click here on _JavaFX and Eclipse_](https://openjfx.io/openjfx-docs/#IDE-Eclipse). Do not use `com.sun.*` stuff. That's internal. – howlger Sep 14 '20 at 09:49
-
[mcve] please .. and don't post too much code in comments, instead edit your question and include those addititional details. That said: when accessing internal api, you have to modify encapsulation of the modules (by add-exports/add-opens to both compile and runtime path) – kleopatra Sep 14 '20 at 10:18
2 Answers
Well, I manage to solve this by myself in probably the most primitive way...
I simply import JavaFX into classpath and manually delete module-info.class
from every JavaFx jar file making JavaFx not modular. Then I just run an app with the mentioned VM arguments and everything was just fine!
I am sure many of you will be able to give me 10 reasons why removing module-info.class
from existing lib is a bad idea but... if it works, and still I think there is no other solution to make my not modular project work with JavaFx 11.

- 31
- 1
- 6
What you did to solve your problem could be achieved in a much simpler way. Just add a line like the following to the file which contains your main class (assumed name MyApp) and then start your app by calling MyAppLauncher.main instead of MyApp.main.
class MyAppLauncher {public static void main(String[] args) {MyApp.main(args);}}
This does the trick so that you can put all jars on the classpath and that way igonre the module system completely without having to remove the module-info.classes manually.

- 10,369
- 2
- 16
- 35
-
I am unable to try this because I have already deleted module-info.class so in my case, this will work anyway cos "my" JavaFx is now not modular! Also a good alternative to solve this problem is just simply downgrade to java8 you do not need to use open jdk and also do not need to pay for using original Oracle java! – Programer001 Sep 15 '20 at 16:48
-
I also do not understand Oracle's logic... Why they ejected JavaFx from JDK making JavaFx external? Why do I need to register and pay for new Java, like Java 11. And what is the purpose of the whole JPMS?! I think JPMS is making already hard things even harder... – Programer001 Sep 15 '20 at 16:56
-
Downgrading to Java 8 is not a solution unless you really assume that there were no improvements between then and now. There are also free alternatives for everything if you do not want to pay anything for Oracle. I only agree with you on the JPMS issue. – mipa Sep 15 '20 at 21:40
-
yes but since there is no clear list of features that were added between javaFx8 and 11 its the same thing for me. And also java 8 is probably still much more popular than java 11 is. – Programer001 Sep 16 '20 at 08:27