Getting IO exception when running Linux command in Java -


i'm writing java app in windows connect linux machine through ssh. i'm getting following exception:

java.io.ioexception: cannot run program ssh: createprocess error=2, cannot find specified file. 

code:

process p = runtime.getruntime().exec("ssh root@xxx.xxx.xxx.xxx ls"); 

while running command in cmd working, not through java. ssh in path environmental vars.

you need interpreter understand ssh command:

process p = runtime.getruntime().exec(new string[]{"cmd", "ssh root@xxx.xxx.xxx.xxx ls"}); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -