I execute some commands using SSHJ, I do it using this method:
private Command executeCommand(String command, SSHClient client) {
Command commandObject = client.startSession().exec(command);
commandObject.join();
return commandObject;
}
It works well until I execute this command:
cd $SOLR; nohup java -Dsolr.solr.home=./solr -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar 2> logs/solr.log &
In this case the whole program hangs on
commandObject.join();
Of course the process it starts is started. Also the same line executed from shell returns right away.
Any idea why and how to overcome this?
EDIT: the same happens when I don't join() but read the sysout of the command (with commons-io):
IOUtils.toString(commandObject.getInputStream()))