SOLVED: Import not recognising class in jar

Answered

I have a set of import statements where I can't see why it's not finding the class in my libraries, e.g.

import org.bson.Document;

In my project libraries, I have /home/user/libraries/mongo-java-driver/bson/build/libs/bson-4.3.0-SNAPSHOT.jar and I can see the class in that jar.

 $ jar tvf ~/libraries/mongo-java-driver/bson/build/libs/bson-4.3.0-SNAPSHOT.jar

...

12236 Wed Mar 10 08:01:40 GMT 2021 org/bson/Document.class

but IDEA says "Cannot resolve symbol 'bson'".

It's there in the JAR, the JAR is in the project libraries. I'm missing something obvious, but what?

0
4 comments

Hello,

Could you please attach screenshot with module dependencies ("ProjectStructure | Modules | Dependencies")?

1

Thank you for that.

What I seem to have been missing is that it doesn't automatically include libraries I've set up, I have to add it to dependencies as well.

0

Does it work fine now?

0

It seems to be working fine.

0

Please sign in to leave a comment.