关于从java调用MatLab函数的错误

时间:2013-09-22 03:55:26

标签: java matlab matlab-deployment matlab-compiler

我正在使用MatLab2013a 64位和Java7。我正在尝试做的是通过javabuilder从Java调用matlab函数,我创建了一个matlab项目来编译函数,以下是我的matlab函数

function SP=imagerotate(filename,theta)
    I=imread(filename);
    SP=imrotate(I,theta);

然后我将它添加到名为RotateImage的类中(这是编译Matlab函数的常用过程)。并且没有发生错误。然后我创建了一个Java项目并添加了distrib\flying.jarC:\Program Files\MATLAB\MATLAB Compiler Runtime\v81\toolbox\javabuilder\jar\javabuilder.jar。当我尝试测试它时,发生了一个错误。

包装图片;

import com.mathworks.toolbox.javabuilder.MWClassID;
import com.mathworks.toolbox.javabuilder.MWNumericArray;
import flying.RotateImage;

/**
 * Created with IntelliJ IDEA.
 * User: ssj-at-work
 * Date: 13-9-22
 * Time: 上午11:00
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main(String args[]) {
        try {
            System.out.println("Begin");
            RotateImage flyingDraw = new RotateImage();
            System.out.println("Middle");
            MWNumericArray theta = new MWNumericArray(90, MWClassID.INT16);
            String filename=new String("C:\\Users\\ssj-at-work\\Desktop\\Picture\\GN20130625_1.jpg");
            Object img[]=null;
            img=flyingDraw.imagerotate(1,filename,theta);
            int[] k=((MWNumericArray) img[0]).getDimensions();
            for (int i:k){
                System.out.println(i);
            }
            System.out.println("Here");
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

错误信息如下

Invalid MEX-file 'F:\Program Files\MATLAB\R2013a\mcr\toolbox\matlab\imagesci\private\rjpg8c.mexw64': 找不到指定的模块。

Error in readjpg (line 12)



Error in imread (line 416)



Error in imagerotate (line 2)



Unable to print provided exception.

Caused by:
    Errors occurred while loading the Settings files. 
    Details: F:\Program Files\MATLAB\R2013a\toolbox\matlab\matlab.settings  Internal Error: Failed to find SAX plugin.
    C:\Users\SSJ-AT~1\AppData\Local\Temp\ssj-at-work\mcrCache8.1\flying0\.matlab\matlab.settings    Internal Error: Failed to find SAX plugin.
    There is no Settings files associated with this product node: matlab. The Settings files may be deleted after MATLAB started up. Please restart MATLAB to fully solve this issue.
    .


Process finished with exit code 255

请帮帮我。

1 个答案:

答案 0 :(得分:0)

  1. 确保系统PATH中对应于MCR 8.1的\ v81 \ bin \ win64 环境变量比MCR 8.0对应的环境变量。
  2. 解决方法是明确地将以下条目添加到系统PATH: \ V81 \ BIN \ Win64的