The correct way is
DB.runCommand( new BasicDBObject( "repairDatabase" ) );
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>
If you are using replicasets then you should make sure the node is not
primary when you do the repair.