title: call MATLAB in Java via MatlabControl.java
body: <p>Recently I am trying to write a java application that can execute matlab code but faced some problems.</p>
  
  <p>First of all, I refer to the link: <a href="http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html" rel="nofollow">http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html</a></p>
  
  <p>It has some tips to execute matlab code under java application. I included the MatlabControl.java as well as jmi.jar, following the steps it gives.</p>
  
  <p>but when I try to test just a piece of simple code as follows</p>
  
  <pre><code>package jmat;
  
  
  public class MainProgram {
  
      public static void main(String[] args) {
          MatlabControl mc = new MatlabControl();
          mc.eval(new String("x=5;"));
      }
  
  }
  </code></pre>
  
  <p>the console outputed the error as follows</p>
  
  <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: com.mathworks.jmi.NativeMatlab.PostMatlabRunnable(JZ)V
      at com.mathworks.jmi.NativeMatlab.PostMatlabRunnable(Native Method)
      at com.mathworks.jmi.NativeMatlab.postMatlabRunnable(NativeMatlab.java:399)
      at com.mathworks.jmi.MatlabLooper.postMatlabRunnable(MatlabLooper.java:178)
      at com.mathworks.jmi.Matlab.whenMatlabReady(Matlab.java:1404)
      at jmat.MatlabControl.eval(MatlabControl.java:88)
      at jmat.MainProgram.main(MainProgram.java:8)
  </code></pre>
  
  <p>I have no idea why it failed in my program, does any one can help me?</p>
  
  <ul>
  <li>MATLAB version: R2009b</li>
  <li>OS: Win7 32bits</li>
  </ul>