首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MATLAB到Java的MATLAB编译器

MATLAB到Java的MATLAB编译器
EN

Stack Overflow用户
提问于 2017-03-07 09:31:48
回答 2查看 599关注 0票数 2

Iam是MATLAB的新手,希望在Java中使用一些MATLAB脚本。我已经尝试过来自MATLAB的教程。我想在Java中使用的MATLAB函数:

代码语言:javascript
复制
    function y = makesqr(x)

     y = magic(x);

这个MATLAB脚本应该打包到一个Java包中。但是,在创建二进制文件失败后,我会得到错误。而且,我可能还没有完全理解它的工作方式。我可以将MATLAB脚本编译成Java,Java包可以在Java代码中运行吗?

Iam使用Windows 64位与Java版本

代码语言:javascript
复制
1.8.0_121-b13

Matlab

代码语言:javascript
复制
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.
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-08 15:28:30

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

安装Java并设置JAVA_HOME路径。这里是一个很好的描述

票数 1
EN

Stack Overflow用户

发布于 2017-09-09 11:45:11

为了能够使用MATLAB编译器将MATLAB文件打包到Java库中,必须安装和配置MATLAB使用的相同版本的JDK。通过运行以下MATLAB命令,可以获得MATLAB安装使用的Java版本:

代码语言:javascript
复制
version -java

此外,必须正确设置JAVA_HOME环境变量。配置Java环境页面包含更多信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42644580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档