Running Shell or System Command in JAVA

倖福魔咒の 提交于 2019-11-29 12:54:55

Try this:

final Runtime rt = Runtime.getRuntime();
rt.exec(your command line here as a single String);

At the risk of repeating myself I'm gonna say it again: java.lang.ProcessBuilder is much better option

Your command is not in any of the directories in the PATH variable. And it is likely not in the "current working directory" of your Java programms process. Either set PATH correctly, or give the full absolute path to the command which you want to run.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!