简体   繁体   中英

execute jar file from remote machine in java

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

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.

PS: PSEXEC will wok only on windows

If the remote machine is linux, you can execute through ssh:

ssh remote@machine.com 'java -jar hellofile.jar'

and you will see the result in the terminal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM