Java Mac OSX上的im4j无法运行命令
我们使用im4j包装器编写了照片客户端程序,以调用ImageMajick来处理照片。 安装程序在Windows操作系统上运行良好,但是当我们在Mac OSX上运行它时,我们不断得到以下异常Java Mac OSX上的im4j无法运行命令,java,imagemagick,Java,Imagemagick,我们使用im4j包装器编写了照片客户端程序,以调用ImageMajick来处理照片。 安装程序在Windows操作系统上运行良好,但是当我们在Mac OSX上运行它时,我们不断得到以下异常 org.im4java.core.InfoException: org.im4java.core.CommandException: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
org.im4java.core.InfoException: org.im4java.core.CommandException: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at org.im4java.core.Info.getBaseInfo(Info.java:201)
at org.im4java.core.Info.<init>(Info.java:96)
at tenw.photos.ImageTransformer.getImageInfo(ImageTransformer.java:474)
at tenw.photos.ImageTransformer.getCenterCoordinates(ImageTransformer.java:517)
at tenw.photos.ImageTransformer.cropCenter(ImageTransformer.java:157)
at tenw.photos.ImageTransformerTest.testCropCenter(ImageTransformerTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:96)
at org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:117)
at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: org.im4java.core.CommandException: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
at org.im4java.core.Info.getBaseInfo(Info.java:189)
... 33 more
Caused by: java.io.IOException: Cannot run program "identify": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:407)
at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
at org.im4java.core.ImageCommand.run(ImageCommand.java:211)
... 34 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
org.im4java.core.InfoException:org.im4java.core.CommandException:java.io.IOException:无法运行程序“标识”:错误=2,没有这样的文件或目录
位于org.im4java.core.Info.getBaseInfo(Info.java:201)
在org.im4java.core.Info.(Info.java:96)
位于tenw.photos.ImageTransformer.getImageInfo(ImageTransformer.java:474)
位于tenw.photos.ImageTransformer.getCenterCoordinates(ImageTransformer.java:517)
位于tenw.photos.ImageTransformer.cropCenter(ImageTransformer.java:157)
位于tenw.photos.ImageTransformerTest.testCropCenter(ImageTransformerTest.java:32)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于junit.framework.TestCase.runTest(TestCase.java:154)
位于junit.framework.TestCase.runBare(TestCase.java:127)
位于junit.framework.TestResult$1.protect(TestResult.java:106)
位于junit.framework.TestResult.runProtected(TestResult.java:124)
运行(TestResult.java:109)
运行(TestCase.java:118)
位于junit.framework.TestSuite.runTest(TestSuite.java:208)
运行(TestSuite.java:203)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于org.apache.maven.surefire.junit.junitsetset.execute(junitsetset.java:96)
位于org.apache.maven.surefire.junit.JUnit3Provider.executeTestSet(JUnit3Provider.java:117)
位于org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:94)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
位于org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
位于org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
位于org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
在org.apache.maven.surefire.booter.SurefireStarter.runsuitesinprocesswhen标记(SurefireStarter.java:107)
位于org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
原因:org.im4java.core.CommandException:java.io.IOException:无法运行程序“identify”:错误=2,没有这样的文件或目录
位于org.im4java.core.ImageCommand.run(ImageCommand.java:215)
位于org.im4java.core.Info.getBaseInfo(Info.java:189)
... 33多
原因:java.io.IOException:无法运行程序“Identifie”:错误=2,没有这样的文件或目录
位于java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
位于org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:407)
位于org.im4java.process.ProcessStarter.run(ProcessStarter.java:312)
位于org.im4java.core.ImageCommand.run(ImageCommand.java:211)
... 34多
原因:java.io.IOException:error=2,没有这样的文件或目录
位于java.lang.UNIXProcess.forkAndExec(本机方法)
位于java.lang.UNIXProcess(UNIXProcess.java:53)
在java.lang.ProcessImpl.start(ProcessImpl.java:91)
位于java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
在PATH变量中可以找到标识命令。
在shell上执行相同的命令时,它工作正常。非常感谢您的帮助。在eclipse的环境变量设置中使用了我的设置路径变量。有人可能会进一步解释为什么JVM在执行命令之前无法拾取path变量我也面临同样的问题。您能告诉我您在eclipse'e环境变量中添加了什么吗?