问题
Hi I am currently using Eclipse Kepler for my java project.
I wanted to use the Octave (the open sourced MatLab) for calculation. Therefore I have tried to use the javaoctave (https://kenai.com/projects/javaoctave) to help me do the calculation in java. However, when I want to compile my code I get the following error:
Exception in thread "main" dk.ange.octave.exception.OctaveIOException: java.io.IOException: Cannot run program "octave": error=2, No such file or directory
at dk.ange.octave.exec.OctaveExec.<init>(OctaveExec.java:102)
at dk.ange.octave.OctaveEngine.<init>(OctaveEngine.java:65)
at dk.ange.octave.OctaveEngineFactory.getScriptEngine(OctaveEngineFactory.java:49)
at learn.CapabilityLearner.connectOctave(CapabilityLearner.java:72)
at learn.CapabilityLearner.connect(CapabilityLearner.java:37)
at learn.CapabilityLearner.<init>(CapabilityLearner.java:24)
at learn.capability.CapabilityMeanVarianceEquation.<init>(CapabilityMeanVarianceEquation.java:10)
at parse.basketball.runner.GetPlayerFrequency.learnSynergyGraph(GetPlayerFrequency.java:102)
at parse.basketball.runner.GetPlayerFrequency.main(GetPlayerFrequency.java:94)
Caused by: java.io.IOException: Cannot run program "octave": error=2, No such file or directory
at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:457)
at java.lang.Runtime.exec(Runtime.java:593)
at dk.ange.octave.exec.OctaveExec.<init>(OctaveExec.java:100)
... 8 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:452)
... 10 more
This java project has been successfully run on a Windows machine with Eclipse Kepler so I think it is not the code I have that contains an error. the wiki has mentioned the error and some explanation is given. However, due to my lack of experience with programming I could not have grasped the meaning of the solutions. Can anyone help me to identify the problem and teach me how I shall fix this?
With many thanks ! :)
PS : the .classpath of the project is as followed:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="matlabcontrol-4.0.0.jar"/>
<classpathentry kind="lib" path="javaoctave-0.6.4.jar" sourcepath="javaoctave-0.6.4.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="commons-math-2.2.jar"/>
<classpathentry kind="lib" path="commons-logging-1.1.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
回答1:
You can easily solve your problem setting up the Factory
OctaveEngineFactory factory = new OctaveEngineFactory();
factory.setOctaveProgram(new File("path_to_octave_executable"));
OctaveEngine octave = factory.getScriptEngine();
bgcode
来源:https://stackoverflow.com/questions/24456795/javaoctave-jar-file-has-failed-in-mac-osx-eclipse