Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
About the usage of JMI (Java Matlab Interface)

Subject: About the usage of JMI (Java Matlab Interface)

From: Gianluca Magnani

Date: 5 May, 2009 12:14:02

Message: 1 of 3

Hello,
I've a question about the usage of JMI. I succeed in including the package within a Java program, I can do almost everything I need, but I wonder if it's the right path: I don't even know if JMI is still developed by anyone. I saw that there's another way to use Java and Matlab together, and this way is a client-server paradigm, using sockets.

So, my question is: is it more convenient to use JMI for Java-Matlab interaction, being sure that it will be supported (by Java and Matlab I mean) for a (relatively) long time or is it smarter to use another method to make Java and Matlab work together?
Any suggestions?

Thank you for the help
Gianluca Magnani

Subject: About the usage of JMI (Java Matlab Interface)

From: Yair Altman

Date: 5 May, 2009 17:34:01

Message: 2 of 3

"Gianluca Magnani" <gianluca.magnaniREMOVE.THIS@gmail.com> wrote in message <gtpaia$i63$1@fred.mathworks.com>...
> Hello,
> I've a question about the usage of JMI. I succeed in including the package within a Java program, I can do almost everything I need, but I wonder if it's the right path: I don't even know if JMI is still developed by anyone. I saw that there's another way to use Java and Matlab together, and this way is a client-server paradigm, using sockets.
>
> So, my question is: is it more convenient to use JMI for Java-Matlab interaction, being sure that it will be supported (by Java and Matlab I mean) for a (relatively) long time or is it smarter to use another method to make Java and Matlab work together?
> Any suggestions?
>
> Thank you for the help
> Gianluca Magnani

JMI is one of the darkest undocumented Matlab black-holes. It is not officially supported nor documented, and may very well break in future Matlab releases. As long as you stick to the Matlab version which you tested then you should be ok (as long as you remember that MathWorks will not answer any support questions). But you cannot rely on forward compatibility.

As an alternative, you can use Matlab as the server, calling your Java code as needed - this is mostly supported/documented and will likely remain this way in future versions, although some of the interface details may change.

If you must use Matlab as a client, consider using another language for the server: Matlab officially supports being called from other (non-Java) languages - refer to the documentation (External Interfaces section - http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/bp_kqh7.html ).

Alternately, you may wish to consider purchasing Matlab's Java Builder toolbox which gives you an officially-supported interface for Java.

Yair Altman
http://UndocumentedMatlab.com
 

Subject: About the usage of JMI (Java Matlab Interface)

From: Gianluca Magnani

Date: 13 May, 2009 08:09:54

Message: 3 of 3

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <gtpta9$n67$1@fred.mathworks.com>...
> JMI is one of the darkest undocumented Matlab black-holes. It is not officially supported nor documented, and may very well break in future Matlab releases. As long as you stick to the Matlab version which you tested then you should be ok (as long as you remember that MathWorks will not answer any support questions). But you cannot rely on forward compatibility.
>
> As an alternative, you can use Matlab as the server, calling your Java code as needed - this is mostly supported/documented and will likely remain this way in future versions, although some of the interface details may change.
>
> If you must use Matlab as a client, consider using another language for the server: Matlab officially supports being called from other (non-Java) languages - refer to the documentation (External Interfaces section - http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/bp_kqh7.html ).
>
> Alternately, you may wish to consider purchasing Matlab's Java Builder toolbox which gives you an officially-supported interface for Java.
>
> Yair Altman
> http://UndocumentedMatlab.com
>

Thank you for your answer. I saw it just today (I think I forgot to add this thread to my watch list!) and so I'm sorry for the late reply.
The main problem is that if I use Matlab as the server, I can just make it monothread: I mean, I wrote a M-File that, once it's started, act as a sockets-server and answers to commands sent by a Java client, but it blocks everything unitl the server it's closed!

I think I have just few choices:
- use JMI hoping that it will work for at least the next two or three releases;
- use Matlab Engine and communication between Matlab and C/C++ (and so I don't need sockets anymore);
- use M-Files with Java embedded and create a monothread Matlab Server;

Thanks again

Gianluca Magnani

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us