ALEENA JOHN
ALEENA JOHN

Reputation: 557

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

Upvotes: 1

Views: 7119

Answers (2)

Daniel Fekete
Daniel Fekete

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

Pavan Kumar K
Pavan Kumar K

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

Related Questions