installing MongoDB java driver

TangoStar picture TangoStar · Jun 20, 2013 · Viewed 23.3k times · Source

I'm really new in Java and also MongoDB world. I would like to use MongoDB and Java. I have downloaded MongoDB driver for java. It is a jar file, my question is how can I use this Jar file. I've used this command but I got an error:

java -jar mongo-java-driver-2.9.3-javadoc.jar 

and the error:

no main manifest attribute, in mongo-java-driver-2.9.3-javadoc.jar

could you please help me to solve the problem?

Answer

gregwhitaker picture gregwhitaker · Jun 20, 2013

First, that is not the correct jar. The jar you are referencing above contains the javadocs.

The driver jar is: mongo-java-driver-2.9.3.jar.

Secondly, you need to add the jar to your project's classpath in order to use it. These are not executable jars. Take a look at the getting started docs here:

http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-driver/#getting-started-with-java-driver

There is no "installing" the driver. You just add it as a dependency in your project and you use it in your code. You do have to install the database itself. The installation packages for the database are available here: http://www.mongodb.org/downloads