If you just need to reload the nginx configuration you don't have to
run a command in the container. You can control the server using signals. So what you need is to send a SIGHUP signal to the nginx docker container. The signal is then propagated to the server which in turn will reload the configuration.
How to do that? All the docker commands are available as REST API. In this case it is Kill a container the one to make. You just need access to the default unix socket (/var/run/docker.sock) the docker daemon is listening to. It can be shared with the java container (as mounted volume) or in alternative, the docker daemon can be configured to listen to TCP sockets.
Assuming you shared the socket, you can now POST a kill request to the docker daemon from inside the java container using curl:
curl --unix-socket /var/run/docker.sock -d "" "http://localhost/containers/<docker_id>/kill?signal=SIGHUP"
where docker_id is the id of the nginx container.
Note: access to the docker daemon on host (either by remote access or by sharing the socket) may run you into security issues as mentioned by @David Maze
If the above scenario is not feasible you could, in alternative, run the command using ssh. Detailed discussion here