package com.sm.mongo;
    import com.mongodb.MongoClient;
    import com.mongodb.MongoClientURI;
    import com.mongodb.client.MongoCollection;
    import com.mongodb.client.MongoDatabase;
    import org.bson.types.ObjectId;
    public class JavaMongoConnection {
    public static void main(String[] args) {
        //System.setProperty("jdk.tls.trustNameService", "true");
        MongoClientURI uri = new MongoClientURI(
                "mongodb+srv://admin:admin123@cluster0-bkruu.mongodb.net/test?retryWrites=true&w=majority");
            MongoClient mongoClient = new MongoClient(uri);
            MongoDatabase database = mongoClient.getDatabase("test");
    }
}
This is my code, and whenever I run this code, I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/MongoClientURI
I looked at java.lang.NoClassDefFoundError when using MongoDB driver and I tried their solution where I went to Run Configurations --> Dependencies and looked under Classpath Entries to make sure that I have bson-xxx.jar, mongodb-driver-xxx.jar, and mongodb-driver-core-xxx.jar listed. I have these listed and despite this, I keep getting the same error as in that stackoverflow post.
Any help would be appreciated.
 
    