Java runtime not able to run command on mac

孤人 提交于 2019-12-12 03:37:36

问题


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?


回答1:


Try using the below code

String[] command = new String[]{"/bin/bash","-c","ffmpeg -version"};            
        Process p = Runtime.getRuntime().exec(command);


来源:https://stackoverflow.com/questions/38170325/java-runtime-not-able-to-run-command-on-mac

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