Home > front end >  Package 'org.json' is declared in module 'json', but module 'com.example.de
Package 'org.json' is declared in module 'json', but module 'com.example.de

Time:01-03

In a project using Maven & JavaFX, I'm trying to add this dependency in my pom.xml

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20180130</version>
</dependency>

I did that - I reloaded my maven changes (using intellij), but I still can't use this package.

When I wrote this in my code:

import org.json.JSONObject;

I've gotten this error

Package 'org.json' is declared in module 'json', but module 'com.example.demo' does not read it

And I don't understand why. I thought I might need to add it in module-info.java, but after some googling I think that I don't, because in that file I have to specify the dependencies for the JavaFX.

So... what does that error mean?

Thanks.

CodePudding user response:

Add this line to your module-info.java:

requires json;

To understand what it means, see:

  • Related