2017-03-07 44 views
2

Iam新增MATLAB,並希望在Java中使用一些MATLAB腳本。 我試過this來自MATLAB的教程。 我的MATLAB的功能,我想在Java中使用:MATLAB to Java with MATLAB compiler

function y = makesqr(x) 

    y = magic(x); 

此MATLAB腳本應該被打包成Java包。 但創建二進制文件失敗後出現錯誤。 另外我可能沒有完全理解它應該工作的方式。 我可以將MATLAB腳本編譯爲Java,並且Java包可以在Java代碼中運行?

蔭使用的是Windows 64位與Java版本

1.8.0_121-b13 

Matlab具有

1.7.0_60-b19 


Loading source files for package makesqr... 
Constructing Javadoc information... 
Standard Doclet version 1.8.0_121 
Building tree for all the packages and classes... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\Class1.html... 
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1.java:109: warning: no @param for args 
    public static void main (String[] args) 
        ^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1.java:59: warning: no @throws for com.mathworks.toolbox.javabuilder.MWException 
    public Class1() throws MWException 
     ^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1.java:88: warning: no @throws for com.mathworks.toolbox.javabuilder.MWException 
    public Class1(MWComponentOptions componentOptions) throws MWException 
     ^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1.java:77: warning: no @throws for com.mathworks.toolbox.javabuilder.MWException 
    public Class1(String pathToComponent) throws MWException 
     ^
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\Class1Remote.html... 
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1Remote.java:58: error: reference not found 
    * @throws java.jmi.RemoteException An error has occurred during the function call or 
    ^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1Remote.java:61: warning: no @throws for java.rmi.RemoteException 
    public Object[] makesqr(int nargout, Object... rhs) throws RemoteException; 
        ^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\Class1Remote.java:64: warning: no @throws for java.rmi.RemoteException 
    void dispose() throws RemoteException; 
     ^
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\MakesqrMCRFactory.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\package-frame.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\package-summary.html... 
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\package-info.java:8: warning: empty 
tag 
* 


^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\package-info.java:15: error: unexpected end tag: 


* 

^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\package-info.java:20: warning: empty 
tag 
* 


^
C:\Users\Documents\MATLAB\makesqr\for_testing\makesqr\package-info.java:26: error: unexpected end tag: 


* 

^
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\makesqr\package-tree.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\constant-values.html... 
Building index for all the packages and classes... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\overview-tree.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\index-all.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\deprecated-list.html... 
Building index for all classes... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\allclasses-frame.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\allclasses-noframe.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\index.html... 
Generating C:\Users\Documents\MATLAB\makesqr\for_testing\doc\html\help-doc.html... 
3 errors 
8 warnings 
Error: An error occurred while shelling out to javadoc (error code = 1). 
Unable to build executable. For more information, pass the -v option to mcc. 
+0

我正在經歷完全相同的問題。你到目前爲止設法解決它? – palvarez89

回答

1

我的解決方案是使用Java JDK 7,而不是Java的8 Matlab的不支持Java 8

安裝Java JDK並設置JAVA_HOME路徑。 Here是一個很好的描述

0

爲了能夠使用MATLAB編譯器將MATLAB文件打包到Java庫中,必須安裝和配置MATLAB使用的相同版本的JDK。 Java版本是MATLAB安裝使用,可以通過運行以下命令MATLAB獲得:

version -java 

此外,JAVA_HOME環境變量必須正確設置。 Configure Your Java Environment頁面包含更多信息。