title: Return value from jar file created from Matlab
body: <p>I have got a Matlab code which at last calculates a vector of indexes. I used library compiler in order to compile matlab code to a java package .jar file.  I exported the jar file in order to run it for my main Java project. The name of the package class is Epidemic.  I imported the jar file (add it as an external jar). In main code I tried to create an object of my class (in jar file). I have already defined the name of the class as Epidemic. Thus, my code:</p>
  
  <pre><code>import epidemic.Epidemic;
  ...
  public static void main(String[] args) throws IOException {
  
      List&lt;Double&gt; list1 = new ArrayList&lt;Double&gt;();
      List&lt;Double&gt; list2 = new ArrayList&lt;Double&gt;();
  
      Epidemic object = new Epidemic(); 
      object.epidemic(list1, list2);
      System.out.println(list1);
  }
  </code></pre>
  
  <p>I add the .jar file to java project using project->Libraries right click add external jars. Netbeans automatically detects object's methods. However I am getting the following errors:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError:  
  com/mathworks/toolbox/javabuilder/internal/MWComponentInstance
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at twittertrendsetters.TwitterTrendSetters.main(TwitterTrendSetters.java:70)
  Caused by: java.lang.ClassNotFoundException:
  com.mathworks.toolbox.javabuilder.internal.MWComponentInstance
  at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 13 more
  </code></pre>
  
  <p>What is the issue here? Am I supposed to add something else in order the jar to work properly?</p>
  
  <p>EDIT: I add the .jar file located in MATLABROOT/toolbox/javabuild/jar/javabuild.jar to my classpath and the class it seems to work. Now I am facing another problem. When I print the list1 which based on html docs takes the output of matlab .m file I got an empty arrayList. Matlab function returns an array Nx1 of doubles. How can I parse it correctly to the java arrayList.</p>
  
  <p>My matlab code:</p>
  
  <pre><code>function eP = epidemic() // zero input
  
  graph = dlmread('graph.edges'); //a graph
  graph_ids=importdata('cms_V3_id.txt');  // indexes of the graph
  
  for index = 1:length(graph)
   grph(index,1) = find(graph_ids == graph(index,1));
   grph(index,2) = find(graph_ids == graph(index,2));
  end
  grph(:,3)= graph(:,3);
  
  grph(end + 1, :, :) = [max(max(grph)) max(max(grph)) 1 ];
  grph =  spconvert(grph);
  
  [S, prev] = brutte_topk2(grph, 3707); //function approximate pagerank result
  eP = graph_ids(S); // returning a list of indexes
  </code></pre>
  
  <p>I tried to use your approach. I create a table of OBject and parse the result into it.</p>
  
  <pre><code>    Epidemic object = new Epidemic(); 
      Object[] result;
      result = object.epidemic(1);
      System.out.println((Double)result[0]);
  </code></pre>
  
  <p>However I am getting javabuilder.MWNumericArray cannot be cast to java.lang.Double. When I print just the reuslt</p>