Execute remote ssh command "which java" (JSch java)

127 views Asked by At

I'm trying to execute command which java remotely via ssh (JSch java).

I have a remote host that when I execute the command which java directly in the shell the output is like "/ltm/rt/oracle/java/jdk1.8/bin/java" that is correct, but when I try to execute the same command remotely via JSch java the output from the server is empty and I have the following error: which: no java in (/usr/local/bin:/usr/bin)

The user I've used for the authentication over ssh is the same that I use to access to the machine directly.

I'm asking for some ideas to bypass this issue. Thanks.

1

There are 1 answers

0
Serena Sforza On BEST ANSWER

Enabling the pseudo-terminal mode the command is executed correctly.