Error: package com.mongodb.client does not exist

I am compiling this on a Suse-12 linux server. I have these jar files in my CLASSPATH
bson-4.5.1.jar js-22.0.0.2.jar mongodb-driver-sync-4.5.1.jar
graal-sdk-22.0.0.2.jar js-scriptengine-22.0.0.2.jar regex-22.0.0.2.jar
gson-2.8.9.jar mongodb-driver-core-4.5.1.jar truffle-api-22.0.0.2.jar

Here is the simple code I am trying to compile:

import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bson.Document;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
public class RetrievingAllDocuments {
        public static void main( String args[] ) {

                // Creating a Mongo client
                 MongoClient mongo = new MongoClient( "localhost" , 27017 );

                // Creating Credentials
                MongoCredential credential;
                credential = MongoCredential.createCredential("dgptest", "dgp", "dgp1234".toCharArray());
                System.out.println("Connected to the database successfully");

                // Accessing the database

                // Retrieving a collection


        }
}

Any help would be appreciated. I did have package com.mongodb.client in the code at the top but same errors.

Hi @Doug_Pisarek,

Welcome to the MongoDB University Forums :sparkles:

The mongodb-java-driver is an uber JAR that contains mongodb-driver , mongodb-driver-core , and bson , you could try removing these three from your classpath and build it and see if that resolves the issue.

In case you have any doubts, please feel free to reach out to us.

Thanks,
Kushagra Kesav

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.