在Mac OS X上,Java Runtime无法在PATH中找到程序 [英] Program can't be found in PATH by Java Runtime on Mac OS X
本文介绍了在Mac OS X上,Java Runtime无法在PATH中找到程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Mac OS X(10.7)上使用 ImageMagick
。我在 MacPorts
的帮助下安装了它。
I am using ImageMagick
on Mac OS X (10.7). I installed it with the help of MacPorts
.
当我现在进入终端并写道:
When I now enter the Terminal and write:
identify image.jpg
它工作正常。
但是现在从Java中执行它时,会抛出以下异常:
But now while executing it from within Java, the following exception gets thrown:
org.im4java.core.CommandException: java.io.FileNotFoundException: identify
通过运行,我可以在 PATH
上看到它:
I can see it's on the PATH
by running:
which identify
并附上回复:
/opt/local/bin/identify
现在运行时:
echo $PATH
我收到回复:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
相同的代码在Windows上完美运行还安装了 ImageMagick
。
The same code works perfectly on Windows where ImageMagick
is also installed.
那么为什么im4java找不到识别
在 PATH
中?
So why is im4java not finding identify
in the PATH
at all?
推荐答案
尝试设置目标目录的搜索路径:
Try setting the search path to the target directory:
import org.im4java.process.ProcessStarter;
ProcessStarter.setGlobalSearchPath("/opt/local/bin");
这篇关于在Mac OS X上,Java Runtime无法在PATH中找到程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文