title: How to resolve ClassNotFoundException: com.mongodb.connection.BufferProvider?
body: <p>I am trying to write simple java code which shows the MongoDB collections on console. I have added mongodb-driver-3.0.0.jar in my classpath.</p>
  
  <p>But when I try to execute the code, it is giving me following error at the line of Database connection:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    com/mongodb/connection/BufferProvider     at
    com.chintan.app.MongoDbJdbc.main(MongoDbJdbc.java:12) Caused by:
    java.lang.ClassNotFoundException:
    com.mongodb.connection.BufferProvider     at
    java.net.URLClassLoader$1.run(Unknown Source)     at
    java.net.URLClassLoader$1.run(Unknown Source)     at
    java.security.AccessController.doPrivileged(Native Method)    at
    java.net.URLClassLoader.findClass(Unknown Source)     at
    java.lang.ClassLoader.loadClass(Unknown Source)   at
    sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)    at
    java.lang.ClassLoader.loadClass(Unknown Source)   ... 1 more</p>
  </blockquote>
  
  <p>Following is my code snippet:</p>
  
  <pre><code>public static void main(String[] args) 
      {
          MongoClient mongoClient = new MongoClient("localhost", 27017); //Exception
  
          @SuppressWarnings("deprecation")
          DB db = mongoClient.getDB("mydb");
          System.out.println("Database connection successfull.");
          ...
          ...
      }
  </code></pre>
  
  <p>What is the problem here? Do I need to add another jar in classpath or there is some version problem?</p>