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- mongodb-driver-sync-4.5.1.jar
graal-sdk- js-scriptengine- regex-
gson-2.8.9.jar mongodb-driver-core-4.5.1.jar truffle-api-

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.

Kushagra Kesav

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