0

I have installed ffprobe in mac and the directory is /usr/local/bin/ffprobe. When I run the ffprobe command in terminal, it works fine but when I run it in eclipse through ProcessBuilder, it does not run and throws exception as Caused by: java.io.IOException: Cannot run program "ffprobe": error=2, No such file or directory. But, when I run ProcessBuilder giving the absolute path of ffprobe, it works fine.

Working code:

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();

But, if args is [ffprobe, -v, quiet, -print_format, json, -show_format, -show_streams, some_url]

it throws error. How can I run ffprobe command without giving absolute path? I have already followed this post but could not help on my issue.

My java process in eclipse is running at

Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/
user123475
  • 1,065
  • 4
  • 17
  • 29
  • Stupid question, but is `/usr/local/bin/` in the `PATH` for the Java process (not for your terminal, unless you're running from the command line) – MadProgrammer Jun 08 '18 at 22:05
  • Yes. I can run ffprobe command in eclipse terminal as well. When I print the path of ffprobe in java code, its clearly showing /usr/local/bin/ffprobe – user123475 Jun 09 '18 at 13:20

1 Answers1

0

Finally, I was able to resolve this with the below steps as mentioned by Sakra at this post:

  1. Create eclipse.sh at /Applications/Eclipse.app/Contents/MacOS/
export ENV_VAR1=/usr/local/bin/
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $@
  1. chmod +x /Applications/Eclipse.app/Contents/MacOS/eclipse.sh

  2. Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.

  3. Force update the LaunchService as

    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app

user123475
  • 1,065
  • 4
  • 17
  • 29