Java mongodb hello world
A simple Java + MongoDB hello world example – how to connect, create database, collection and document, save, update, remove, get and display document (data).
Tools and technologies used :
  1. MongoDB 2.2.3
  2. MongoDB-Java-Driver 2.10.1
  3. JDK 1.6
  4. Maven 3.0.3
  5. Eclipse 4.2
P.S Maven and Eclipse are both optional, just my personal favorite development tool.

1. Create a Java Project

Create a simple Java project with Maven.
mvn archetype:generate -DgroupId=com.mkyong.core -DartifactId=mongodb 
  -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

2. Get Mongo Java Driver

Download mongo-java driver from github. For Maven users, declares mongo-java driver in pom.xml.
pom.xml
 ...>
  
 
 
  org.mongodb