Java运行时无法在mac上运行命令 [英] Java runtime not able to run command on mac
本文介绍了Java运行时无法在mac上运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Runtime.getRuntime()。exec(ffmpeg);
它抛出IOException
无法运行程序ffmpeg:error = 2,否文件或目录。
任何想法如何解决?
解决方案
尝试使用以下代码
String [] command = new String [] {/ bin / bash, - c,ffmpeg -version};
进程p = Runtime.getRuntime()。exec(command);
I installed ffmpeg on mac through brew install. When i run ffmpeg command from terminal, it is running fine. But when i create a program in java and execute command like
Runtime.getRuntime().exec("ffmpeg");
It is throwing IOException Cannot run program "ffmpeg":error=2, No such file or directory. Any idea how to resolve it?
解决方案
Try using the below code
String[] command = new String[]{"/bin/bash","-c","ffmpeg -version"};
Process p = Runtime.getRuntime().exec(command);
这篇关于Java运行时无法在mac上运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文