1

I am trying to execute a simple hello world program in MongoDB.

I have compiled my java file using

javac -classpath mongo-2.10.0.jar HelloWorld

what to do next. Should I create the jar for the classfile and execute or directly run the class file. I m new to MongoDB.

3
  • Whatever may be the DB..You can run a simple JDBC program directly with java command from command prompt or unix shell Commented Mar 3, 2014 at 12:50
  • I tried using java HelloWorld Its not working Commented Mar 3, 2014 at 12:53
  • Can you post the error log. Commented Mar 3, 2014 at 12:59

1 Answer 1

1

You have several options:

  1. You can run it with:

    java -cp mongo-2.10.0.jar:. HelloWorld

  2. Use maven or gradle to build / run the project.

  3. Create one jar out of your project files.

For simple testing, I would go with 1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.