JAR 文件由 ffmpeg.exe 文件组成,它可以在我的机器上正常运行,没有任何问题。但是,如果我尝试在另一台计算机上运行它,它会告诉我 java.io.IOException: Cannot run program "ffmpeg.exe": CreateProcess error=2,The system cannot find the file specified
从堆栈跟踪。我导入它的方式是
FFMpeg ffmpeg = new FFMpeg("ffmpeg.exe"); //in res folder
...
//ffmpeg class
public FFMPEG(String ffmepgEXE) {
this.ffmepgEXE = ffmepgEXE;
}
最佳答案
快速解决方法是您必须输入 ffmpeg.exe
与您的.jar
在同一个文件夹中文件。
如果你想从 resources
读取文件文件夹,您必须更改此代码:
URL resource = Test.class.getResource("ffmpeg.exe");
String filepath = Paths.get(resource.toURI()).toFile().getAbsolutePath();
FFMpeg ffmpeg = new FFMpeg(filepath);
关于Java JAR 文件在本地机器上运行,但在其他机器上缺少文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71963165/