在Java中从远程计算机执行jar文件 [英] execute jar file from remote machine in java

查看:155
本文介绍了在Java中从远程计算机执行jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个jar文件.我使用Java中的ssh将该jar文件复制到远程计算机中.

I have created a jar file.I copy this jar file into remote machine using ssh in java.

我想从我的机器上执行这个jar文件,并在我的机器上查看结果.

I want to execute this jar file from my machine and see the result in my machine.

java -jar <filename>

我使用

Runtime.getRuntime().exec("java -jar hellofile.jar");

有什么建议吗?请回答

推荐答案

如果远程计算机是linux,则可以通过ssh执行:

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

这篇关于在Java中从远程计算机执行jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆