[英]cannot run command with processbuilder or runexec inside eclipse
[英]ProcessBuilder start() method to run command (ffprobe) in eclipse/mac
我已經在Mac中安裝了ffprobe,目錄是/ usr / local / bin / ffprobe。 當我在終端中運行ffprobe命令時,它工作正常,但當我通過ProcessBuilder在eclipse中運行它時,它無法運行並引發異常, Caused by: java.io.IOException: Cannot run program "ffprobe": error=2, No such file or directory.
但是,當我運行ProcessBuilder給出ffprobe的絕對路徑時,它可以正常工作。
工作代碼:
sample args:[/usr/local/bin/ffprobe, -v, quiet, -print_format, json, -show_format, -show_streams, some_url]
ProcessBuilder pb = new ProcessBuilder(cmdArgs);
Process proc = pb.start();
但是,如果args為[ffprobe, -v, quiet, -print_format, json, -show_format, -show_streams, some_url]
它引發錯誤。 如何在不給出絕對路徑的情況下運行ffprobe命令? 我已經關注了這篇文章,但是無法解決我的問題。
我在Eclipse中的Java進程運行在
Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/
最終,我可以按照Sakra在這篇文章中提到的以下步驟解決此問題:
export ENV_VAR1=/usr/local/bin/ logger "`dirname \\"$0\\"`/eclipse" exec "`dirname \\"$0\\"`/eclipse" $@
chmod + x /Applications/Eclipse.app/Contents/MacOS/eclipse.sh
打開Eclipse.app Info.plist,並將CFBundleExecutable鍵的值從eclipse更改為eclipse.sh。
強制將LaunchService更新為
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.