Reputation: 557
I have created a jar file.I copy this jar file into remote machine using ssh in java.
I want to execute this jar file from my machine and see the result in my machine.
java -jar <filename>
I use
Runtime.getRuntime().exec("java -jar hellofile.jar");
Any suggesions ? Please answer
Upvotes: 1
Views: 7119
Reputation: 5028
If the remote machine is linux, you can execute through ssh:
ssh [email protected] 'java -jar hellofile.jar'
and you will see the result in the terminal
Upvotes: 1
Reputation: 1376
Create a batch file to execute java -jar hellofile.jar from remote cmd.
Now run the batch file from your local machine by PSEXEC \othermachine z:\program.exe. You will need administrator privileges on the target machine.
P.S: PSEXEC will wok only on windows
Upvotes: 1