Pass commands to container processes using Java API

I need to pass a command to a docker process. The command needs to be passed within a Java app.
It should be an equivalent of “docker exec -it cli bash” followed by the command but in Java (not command line).