简体   繁体   English

如何通过Java程序从特定路径运行终端命令?

[英]How to run a terminal command by java program from a specific path?

For example, I have a jar file at "/home/ashish/dev/app" and the command which I have to execute is "java -jar SFTPJava-0.jar xxxxxx" . 例如,我在"/home/ashish/dev/app"有一个jar文件,我必须执行的命令是"java -jar SFTPJava-0.jar xxxxxx" Then how to run this command from java? 那么如何从Java运行此命令?

You can call it windows commandline style from java: see https://crunchify.com/how-to-run-windowsmac-commands-in-java-and-return-the-text-result/ 您可以从Java中将其称为Windows命令行样式:请参阅https://crunchify.com/how-to-run-windowsmac-commands-in-java-and-return-the-text-result/

Maybe this is also intresting for you: using Runtime.exec() in Java 也许这对您也很有趣: 在Java中使用Runtime.exec()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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