Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven not finding dependencies in IntelliJ

I'm new to Maven and not quite sure what it's for but I thought it was for importing external libraries so that they are available while coding. I have imported the dependency and there's no error on it as can be seen here:

enter image description here

But when typing the import it all just comes up in red as if it's not found. It's not finding anything.

enter image description here

And if I paste the whole import line in it gets deleted automatically.

Is this not what Maven is supposed to do or is there something else to do before it will work? I also have it set to import Maven projects automatically.

EDIT: Just for clarity, of course it's in my pom.xml file otherwise it wouldn't be showing up in the external libraries in the screenshot above:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>11</version>
    </dependency>
    <dependency>
        <groupId>uk.co.caprica</groupId>
        <artifactId>vlcj</artifactId>
        <version>4.5.0</version>
    </dependency>
    <dependency>
        <groupId>uk.co.caprica</groupId>
        <artifactId>vlcj-javafx</artifactId>
        <version>1.0.2</version>
    </dependency>
</dependencies>

Additional EDIT: Some screenshots to show that typing the classes directly does not work any better. Intellij is just not finding anything:

enter image description here enter image description here

like image 906
Hasen Avatar asked Jan 01 '26 08:01

Hasen


1 Answers

It seems this particular dependency is modularised per the Java Platform Module System. So, we need requires in the module-info.java file.

module com.sample {
    requires javafx.controls;
    exports com.sample;
    requires transitive javafx.graphics;
    requires uk.co.caprica.vlcj;
    requires uk.co.caprica.vlcj.javafx;
}

After this the dependency is suddenly visible and fully usable within the code.

like image 152
Hasen Avatar answered Jan 03 '26 10:01

Hasen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!