The `mongo` shell provides a JavaScript interface to MongoDB, but the underlying communication to the MongoDB server for all drivers uses the MongoDB Wire Protocol:
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/. This means there isn't an equivalent of a generic "execute" for a string on the server; you have to use the interface provided by your driver.
It sounds like you are both looking for a Java interface which is higher level than the standard MongoDB Java driver .. do you have more details on your use cases? For example, if you are intending to pass through user-provided input directly to MongoDB you should definitely reconsider (best practice would be to build up the query programmatically so you can sanity check the values provided and perhaps abstract some of the implementation details).
You might want to look into the Jongo community-supported driver, whose goal is to "Query in Java as in Mongo Shell":
http://jongo.org/.