In Java and using Jongo you can do the following:
MongoCollection col = new Jongo(DbConfigurer.getDB()).getCollection("CODE");
col.getDBCollection().rename("CODE45", true);
I've just tested and it works.
Now using the 'runCommand' (same than using db.command) in the following example:
DB db = ....getDB();
Jongo jongo = new Jongo(db);
jongo.runCommand("{ renameCollection : 'OLD_NAME', to: 'NEW_NAME', dropTarget: true}");
I obtain the same error you have.
I read from some documentation you have to connect first to admin database to process some of the command not allowed, so i did the same but with "admin" db, and i obtain the following error stack:
{ "serverUsed" : "localhost/127.0.0.1:27017" ,
"errmsg" : "exception: invalid collection name: NEW_NAME" , "code" : 15967 , "ok" : 0.0}
Strange to have such different behaviors...