2

What I got from the documentation is, It runs as a separate process on other machine and I can communicate with it using the mongo db client driver for java and I can do normal operations.

But I doubt If I can use MongoDB as an embedded db in my java application? I mean, not as a separate process on other machine or not as a separate process on the same machine. It should be part of java application.

Can you please help me out?

1

1 Answer 1

8

No, that's not possible. MongoDB is a native C++ application that uses memory-mapped files, opens sockets, etc. It won't run in a JVM.

Also, MongoDB was made for web scale applications, big data, failover clusters (replica sets) and auto-sharding, none of which really make sense in an embedded application. Also, it's quite aggressive in terms of memory usage which is undesirable for embedded applications.

--EDIT after zero323's comment--

You might want to take a look at db4o an object database for java that was made for embedding.

Also, when embedding databases, the licenses can bite you and force you to release your code under the same license, in case of MongoDB the AGPL.

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

1 Comment

...and having your whole code infected with the AGPL can be really cumbersome, because it requires you to license it to everyone who uses it over a network. With a normal GPL application it's OK to keep the source when it only runs on your own servers.

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.