Hey @kushagra_kartik,
Welcome to MongoDB Community forums!
The java.lang.NoClassDefFoundError generally indicates that a class is missing during runtime (not during the build/compile process). To address this, please open the “Run Configurations” dialog for your project and ensure that the mongodb-driver-xxx.jar is listed in the Classpath tab.
Also, if you’d like to reference code samples, please take a look at the Java - Quick Start Project.
Best regards,
Kushagra