<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calling Java from MATLAB</title>
	<atom:link href="http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/</link>
	<description>Mike works on the MATLAB Desktop team</description>
	<lastBuildDate>Mon, 13 Feb 2012 21:06:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Michael Katz</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8470</link>
		<dc:creator>Michael Katz</dc:creator>
		<pubDate>Mon, 06 Feb 2012 21:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8470</guid>
		<description>@Ullas,
 I&#039;m afraid that I&#039;m not familiar with the Lookup class. Please contact technical support for more detailed assitance.

@Ritu,
 You need to make sure that class (or it&#039;s jar) is on MATLAB&#039;s java path. See the documentation: &lt;a href=&quot;www.mathworks.com/help/techdoc/ref/javaaddpath.html&quot; rel=&quot;nofollow&quot;&gt;www.mathworks.com/help/techdoc/ref/javaaddpath.html&lt;/a&gt;. If you need further assistance, contact Technical support and they can walk you through it.</description>
		<content:encoded><![CDATA[<p>@Ullas,<br />
 I&#8217;m afraid that I&#8217;m not familiar with the Lookup class. Please contact technical support for more detailed assitance.</p>
<p>@Ritu,<br />
 You need to make sure that class (or it&#8217;s jar) is on MATLAB&#8217;s java path. See the documentation: <a href="www.mathworks.com/help/techdoc/ref/javaaddpath.html" rel="nofollow">http://www.mathworks.com/help/techdoc/ref/javaaddpath.html</a>. If you need further assistance, contact Technical support and they can walk you through it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ritu</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8424</link>
		<dc:creator>Ritu</dc:creator>
		<pubDate>Tue, 31 Jan 2012 10:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8424</guid>
		<description>Hi

I am facing this problem while using a third party jar (stanford-parser.jar) function from matlab. Code snippet is as following


grammarResPath = java.lang.String(&#039;C:\stanford-parser-2011-09-14\grammar\englishPCFG.ser.gz&#039;);
lp = javaObject(&#039;edu.stanford.nlp.parser.lexparser.LexicalizedParser&#039;, grammarResPath);
tf = PTBTokenizer.factory(false, WordTokenFactory());
tp = TreePrint(&#039;penn,dependencies,wordsAndTags&#039;);


All three lines call for some class constructors of jar. Second line of this code throws &quot;java.lang.IllegalArgumentException: name&quot;. To verify if it is java version conflict or some other configuration issue, I commented second line....rest of the lines work fine. What  could be the issue? Kindly help.</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I am facing this problem while using a third party jar (stanford-parser.jar) function from matlab. Code snippet is as following</p>
<p>grammarResPath = java.lang.String(&#8216;C:\stanford-parser-2011-09-14\grammar\englishPCFG.ser.gz&#8217;);<br />
lp = javaObject(&#8216;edu.stanford.nlp.parser.lexparser.LexicalizedParser&#8217;, grammarResPath);<br />
tf = PTBTokenizer.factory(false, WordTokenFactory());<br />
tp = TreePrint(&#8216;penn,dependencies,wordsAndTags&#8217;);</p>
<p>All three lines call for some class constructors of jar. Second line of this code throws &#8220;java.lang.IllegalArgumentException: name&#8221;. To verify if it is java version conflict or some other configuration issue, I commented second line&#8230;.rest of the lines work fine. What  could be the issue? Kindly help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ullas</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8396</link>
		<dc:creator>Ullas</dc:creator>
		<pubDate>Mon, 23 Jan 2012 04:02:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8396</guid>
		<description>Hello Michael,

We have developed a simple class in the Netbeans IDE. This class is having a method which internally calls the “Lookup” for getting a reference of the Assembly Factory class. 

Observations:
1.The compiled classes works properly when started from the dos command prompt (thus starting a new JVM with java cmd).
2.Instantiating the class within MATLAB (which has a standard JVM already started) does not work(returning null) due to the Lookup class used in the assembly class (other “standard” classes works fine without Lookup).

Please can you give any idea why “Lookup” class is not working in MATLAB or do we require any dependencies?
Also provide us some examples with Lookup class how it is used in the MATLAB. 

Note – Included all dependent jars which are used by the Project in the MATLAB java search path.

Thanks,
Ullas</description>
		<content:encoded><![CDATA[<p>Hello Michael,</p>
<p>We have developed a simple class in the Netbeans IDE. This class is having a method which internally calls the “Lookup” for getting a reference of the Assembly Factory class. </p>
<p>Observations:<br />
1.The compiled classes works properly when started from the dos command prompt (thus starting a new JVM with java cmd).<br />
2.Instantiating the class within MATLAB (which has a standard JVM already started) does not work(returning null) due to the Lookup class used in the assembly class (other “standard” classes works fine without Lookup).</p>
<p>Please can you give any idea why “Lookup” class is not working in MATLAB or do we require any dependencies?<br />
Also provide us some examples with Lookup class how it is used in the MATLAB. </p>
<p>Note – Included all dependent jars which are used by the Project in the MATLAB java search path.</p>
<p>Thanks,<br />
Ullas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Katz</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8350</link>
		<dc:creator>Michael Katz</dc:creator>
		<pubDate>Mon, 16 Jan 2012 13:39:50 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8350</guid>
		<description>@Ullas,

 I&#039;m not familiar with that particular class, but what MATLAB is complaining about is that the static methods can&#039;t be followed on the same line with a method invocation. You&#039;ll need to &quot;Law of Demeter&quot; on this call. Try something like:

&lt;pre class=&quot;code&quot;&gt;
assemblyFacory = lookup_object.lookup(assemblyFactory)
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Ullas,</p>
<p> I&#8217;m not familiar with that particular class, but what MATLAB is complaining about is that the static methods can&#8217;t be followed on the same line with a method invocation. You&#8217;ll need to &#8220;Law of Demeter&#8221; on this call. Try something like:</p>
<pre class="code">
assemblyFacory = lookup_object.lookup(assemblyFactory)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ullas</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8346</link>
		<dc:creator>Ullas</dc:creator>
		<pubDate>Sat, 14 Jan 2012 17:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8346</guid>
		<description>Hello Michael,

Thanks for immediate Response!

Michael, I am trying to execute equivalent line of code “AssemblyFactory  assemblyFactory = Lookup.getDefault().lookup(AssemblyFactory.class);” in Matlab. I mean I am trying to get reference of the &quot;AssemblyFactory&quot; class using Lookup class but it’s not working. 

My matlab code is 

import org.openide.util.*;
%creating string varaible
CurrentDevice = &#039;dsPIC33FJ256GP710&#039;;
%Creating object from the MCAssemblyFactory
assemblyFactory = com.microchip.mplab.mdbcore.assemblies.assemblyfactory.MCAssemblyFactory;

% Creating Lookup object
loookup_object = Lookup.getDefault();

%AssemblyFactory  assemblyFactory = Lookup.getDefault().lookup(AssemblyFactory.class);
assemblyFactory = Lookup.getDefault().lookup.(assemblyFactory);

%%%%%%%%%%%% end of code  %%%%%%%%%%%%%%%

%% Note I have added all related jar files to matlab jave path.

I am getting error as 
&quot;Static method or constructor invocations cannot be indexed.
Do not follow the call to the static method or constructor with
any additional indexing or dot references.&quot;

Can you help me how to use Lookup class in Matlab with some examples. 

Thanks in Advance.</description>
		<content:encoded><![CDATA[<p>Hello Michael,</p>
<p>Thanks for immediate Response!</p>
<p>Michael, I am trying to execute equivalent line of code “AssemblyFactory  assemblyFactory = Lookup.getDefault().lookup(AssemblyFactory.class);” in Matlab. I mean I am trying to get reference of the &#8220;AssemblyFactory&#8221; class using Lookup class but it’s not working. </p>
<p>My matlab code is </p>
<p>import org.openide.util.*;<br />
%creating string varaible<br />
CurrentDevice = &#8216;dsPIC33FJ256GP710&#8242;;<br />
%Creating object from the MCAssemblyFactory<br />
assemblyFactory = com.microchip.mplab.mdbcore.assemblies.assemblyfactory.MCAssemblyFactory;</p>
<p>% Creating Lookup object<br />
loookup_object = Lookup.getDefault();</p>
<p>%AssemblyFactory  assemblyFactory = Lookup.getDefault().lookup(AssemblyFactory.class);<br />
assemblyFactory = Lookup.getDefault().lookup.(assemblyFactory);</p>
<p>%%%%%%%%%%%% end of code  %%%%%%%%%%%%%%%</p>
<p>%% Note I have added all related jar files to matlab jave path.</p>
<p>I am getting error as<br />
&#8220;Static method or constructor invocations cannot be indexed.<br />
Do not follow the call to the static method or constructor with<br />
any additional indexing or dot references.&#8221;</p>
<p>Can you help me how to use Lookup class in Matlab with some examples. </p>
<p>Thanks in Advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Katz</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8334</link>
		<dc:creator>Michael Katz</dc:creator>
		<pubDate>Wed, 11 Jan 2012 13:10:21 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8334</guid>
		<description>@Ullas,

 I&#039;m not sure what you&#039;re looking for, but try &lt;a href=&quot;http://www.mathworks.com/matlabcentral/answers/&quot; rel=&quot;nofollow&quot;&gt;MATLAB Answers&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Ullas,</p>
<p> I&#8217;m not sure what you&#8217;re looking for, but try <a href="http://www.mathworks.com/matlabcentral/answers/" rel="nofollow">MATLAB Answers</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ullas</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8333</link>
		<dc:creator>Ullas</dc:creator>
		<pubDate>Wed, 11 Jan 2012 09:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-8333</guid>
		<description>how to access Lookup class in matlab with example;</description>
		<content:encoded><![CDATA[<p>how to access Lookup class in matlab with example;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maria</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7974</link>
		<dc:creator>Maria</dc:creator>
		<pubDate>Fri, 05 Aug 2011 09:38:20 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7974</guid>
		<description>Sorted my own problem, clearing java did it. 
Oh well.
Thanks anyway.
Maria</description>
		<content:encoded><![CDATA[<p>Sorted my own problem, clearing java did it.<br />
Oh well.<br />
Thanks anyway.<br />
Maria</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maria</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7972</link>
		<dc:creator>Maria</dc:creator>
		<pubDate>Thu, 04 Aug 2011 13:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7972</guid>
		<description>Hello, thanks for taking the time to answer all those questions, they are very helpful.

I am still having some trouble with a very simple example of something I want to expand on. 

I have two different classes I want to import, neither of which is packaged. First one is called simpleclass.class, has a constructor, has to methods that simple add a few numbers and that&#039;s it. In Matlab I import it, create an instance of it, and use its methods, no problems. I can list the methods available with methodsview, it shows with the inmem command, everything.

Then I have a second class. It&#039;s in another directory, but I have added this one to the javaclasspath as well. The other major difference is this class extends another class from a program&#039;s API. When I try the same code that works for simpleclass with this one, I get &quot;Arguments to IMPORT must either end with &quot;.*&quot;
 or else specify a fully qualified class name: &quot;AOTWrapper&quot; fails this test.&quot; If I add the &quot;.*&quot;, I get the following message: &quot;No class AOTWrapper can be located or no methods for class&quot;.

I have added the path to the jar file from the API to the javaclasspath, but it doesn&#039;t work either. 

Do I need to import that jar file into the matlab code before the other one? 

Thanks very much in advance for your time.

Kind regards
Maria</description>
		<content:encoded><![CDATA[<p>Hello, thanks for taking the time to answer all those questions, they are very helpful.</p>
<p>I am still having some trouble with a very simple example of something I want to expand on. </p>
<p>I have two different classes I want to import, neither of which is packaged. First one is called simpleclass.class, has a constructor, has to methods that simple add a few numbers and that&#8217;s it. In Matlab I import it, create an instance of it, and use its methods, no problems. I can list the methods available with methodsview, it shows with the inmem command, everything.</p>
<p>Then I have a second class. It&#8217;s in another directory, but I have added this one to the javaclasspath as well. The other major difference is this class extends another class from a program&#8217;s API. When I try the same code that works for simpleclass with this one, I get &#8220;Arguments to IMPORT must either end with &#8220;.*&#8221;<br />
 or else specify a fully qualified class name: &#8220;AOTWrapper&#8221; fails this test.&#8221; If I add the &#8220;.*&#8221;, I get the following message: &#8220;No class AOTWrapper can be located or no methods for class&#8221;.</p>
<p>I have added the path to the jar file from the API to the javaclasspath, but it doesn&#8217;t work either. </p>
<p>Do I need to import that jar file into the matlab code before the other one? </p>
<p>Thanks very much in advance for your time.</p>
<p>Kind regards<br />
Maria</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yair Altman</title>
		<link>http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7942</link>
		<dc:creator>Yair Altman</dc:creator>
		<pubDate>Wed, 13 Jul 2011 00:54:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/desktop/2009/07/06/calling-java-from-matlab/#comment-7942</guid>
		<description>@Naresh and @Sarah - 

There are several different ways you can call Matlab from Java, but none of them are supported or documented, so you should be very careful if you plan to use it in Production code:

1. Use JNI to directly call the Matlab DLLs. For example: http://jmatlink.sourceforge.net , http://www.jstatcom.com/jmatlab.html or https://jna.dev.java.net . JNA in particular is quite easy to use, once you get over the initial setup.

2. Use RMI/JMI to directly access the Java engine: http://UndocumentedMatlab.com/blog/jmi-java-to-matlab-interface/ and the follow-up articles in that series

3. Use a Java-COM bridge (for example, JACOB or JCOM)

4. Use DDE. An example for a .Net client that you can adapt: http://www.codeproject.com/KB/dotnet/matlabeng.aspx

5. There are several other alternatives, but I suggest you stick to the above. #1 and #2 are your best bets.

- Yair</description>
		<content:encoded><![CDATA[<p>@Naresh and @Sarah &#8211; </p>
<p>There are several different ways you can call Matlab from Java, but none of them are supported or documented, so you should be very careful if you plan to use it in Production code:</p>
<p>1. Use JNI to directly call the Matlab DLLs. For example: <a href="http://jmatlink.sourceforge.net" rel="nofollow">http://jmatlink.sourceforge.net</a> , <a href="http://www.jstatcom.com/jmatlab.html" rel="nofollow">http://www.jstatcom.com/jmatlab.html</a> or <a href="https://jna.dev.java.net" rel="nofollow">https://jna.dev.java.net</a> . JNA in particular is quite easy to use, once you get over the initial setup.</p>
<p>2. Use RMI/JMI to directly access the Java engine: <a href="http://UndocumentedMatlab.com/blog/jmi-java-to-matlab-interface/" rel="nofollow">http://UndocumentedMatlab.com/blog/jmi-java-to-matlab-interface/</a> and the follow-up articles in that series</p>
<p>3. Use a Java-COM bridge (for example, JACOB or JCOM)</p>
<p>4. Use DDE. An example for a .Net client that you can adapt: <a href="http://www.codeproject.com/KB/dotnet/matlabeng.aspx" rel="nofollow">http://www.codeproject.com/KB/dotnet/matlabeng.aspx</a></p>
<p>5. There are several other alternatives, but I suggest you stick to the above. #1 and #2 are your best bets.</p>
<p>- Yair</p>
]]></content:encoded>
	</item>
</channel>
</rss>

