0

I'm using OpenJDK 11, IntelijIDEA 2019.2 and javafx-sdk-11.0.2.

When I wrote JavaFX project, I tried to add external runnable jar from maven project, but IntelijIDEA didn't see classes for this jar.

What I've done:

I added as external library own jar. enter image description here

In the project tree I found it:

enter image description here

But I couldn't create class objects and use methods that contains this jar: enter image description here

Why it happens?

invzbl3
  • 5,872
  • 9
  • 36
  • 76

1 Answers1

0

If it's modular project
The reason was the use of the file module-info.java. As we know, JavaFX 11 is not part of the JDK anymore. So, we need to add this special file at the root of our packages w/ lines like:

module modulename {
    requires javafx.fxml;
    requires javafx.controls;

    opens package;
}

From this moment, most likely you won't find classes until you add separately your jar in this code like:

requires name_of_jar;

Only after adding this, you can use your classes/methods from external libs.


If it's non-modular project
As mentioned by mipa, you can follow these instructions as alternative way.


Related links:

invzbl3
  • 5,872
  • 9
  • 36
  • 76
  • 1
    Just in order to avoid any confusion. In order to use JavaFX 11 or higher you do not have to modularize your application and there is no need to create any module-info.java file. Just follow the instructions here: https://openjfx.io/openjfx-docs/ – mipa Aug 03 '19 at 12:15
  • Thanks, mipa, useful info. I'll add it to the answer as alternative way. – invzbl3 Aug 03 '19 at 17:18