Use mongosh shell command through the java language

how can I use mongosh shell command through the java language like navicat does

  I have a scence, users input the mongosh shell command, back-end recieve these commands, and query from the mongodb, then return the query result to users.
  But now, mongo had abandoned the "eval " command which can realize the scence I need. 
  So, is there any way else can realize the scence?
  Thank you so much!!!

The mongosh shell as most shell probably use stdin and stdout. As such you might be able to simply fork the shell from Java, then read and write to it using stdin and stdout streams.

Thanks for your replying , But I need to execute the native query like “db.collectionName.find();” through java in Spring, just like mysql-jdbc execute the sql through java, but now the mongo-driver seem to not support this operation.

I really do not understand. What do you mean by

Find in java is

Don’t use mongosh to replace the MongoDB Java driver.

Check out this template: