2

Iam new to MATLAB and want to use some MATLAB scripts in Java. I have tried this tutorial from MATLAB. My MATLAB function i want to use in Java:

    function y = makesqr(x)

     y = magic(x);

This MATLAB script should be Packaged into a Java Package. but i get Errors after creating Binaries fails. Also i have probably not completly understood the way it should work. I can compile the MATLAB script to Java, and the Java Package can be run in Java code ?

Iam using Windows 64 bit with Java version

1.8.0_121-b13

Matlab has

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.
1
  • I'm going through exactly the same problem. Have you managed to solve it so far? Commented Mar 8, 2017 at 14:44

2 Answers 2

1

My solution was to use Java JDK 7 instead of Java 8. Matlab does not support Java 8.

Install Java JDK and set the JAVA_HOME path. Here is a good description

Sign up to request clarification or add additional context in comments.

Comments

0

In order to be able to use MATLAB Compiler to package MATLAB files into Java libraries, the same version of JDK that MATLAB uses must be installed and configured. The version of Java that MATLAB installation is using can be obtained by running the following MATLAB command:

version -java

Also, the JAVA_HOME environment variable must be set properly. The Configure Your Java Environment page contains more information.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.