title: How do I execute a MongoDB js script using the Java MongoDriver
body: <p>I have implemented a JavaScript function inside the Mongodb server using <a href="http://docs.mongodb.org/manual/tutorial/store-javascript-function-on-server/" rel="noreferrer">this example</a>.</p>
  
  <p>It works fine when I use mongo shell, but I want to run it from inside a Java program. This is the code:</p>
  
  <pre><code>public String runFunction() {
  
      CommandResult commandResult1 = db.command("db.loadServerScripts()");
      CommandResult commandResult2 = db.command("echoFunction(3)");
  
      return commandResult2.toString();
  }
  </code></pre>
  
  <p>I don't understand the result.</p>