title: How to Run .jar methods from Javascript
body: <p>I have a java jar with classes in it. I need to be able to call a method in one of those classes. It has to be on the client side locally, not ajax calls to a server not webservices. I have the .jar right next to my html page and I need to be able to make a java method call from javascript/html.</p>
  
  <p>I just need <strong>a way</strong> to call the java method, these ways I tried might not even be the best way to do it. Just looking for some help.</p>
  
  <p>I have tried multiple ways already all of with no prevail. Maybe I did something wrong, or <code>&lt;applet&gt;</code> is no longer supported by <a href="https://support.google.com/chrome/answer/6213033" rel="nofollow">chrome v42 and up.</a>    </p>
  
  <p><strong>Java</strong> class inside of <strong>.jar</strong></p>
  
  <pre><code>import java.applet.Applet;
  
  
  public class MethodInvocation extends Applet{
  
      public String helloWorld() {
          System.out.println("Hello World!");
          return "Hello JavaScript, I came from Java";
      }
  
  }
  </code></pre>
  
  <p><strong>First Attempt</strong> - Didn't work get that <a href="https://support.google.com/chrome/answer/6213033" rel="nofollow">chrome</a> message</p>
  
  <pre><code>    &lt;applet archive="JavaLibrary.jar" code="MethodInvocation.class" name="myApplet" width="1" height="1"&gt;&lt;/applet&gt;
  
      &lt;script language="javascript"&gt;
          var javaMessage = document.myApplet.helloWorld();
          console.log("Java Message Received: " + javaMessage);
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>Second Attempt</strong> - Applet shows up with puzzle piece in middle of it saying "The plugin is not supported" and in the console I this error <code>Uncaught ReferenceError: app is not defined</code>.</p>
  
  <pre><code>&lt;object type="application/x-java-applet" height="300" width="550"&gt;
      &lt;param name="id" value="app"&gt;
      &lt;param name="code" value="MethodInvocation"&gt;
      &lt;param name="archive" value="JavaLibrary.jar"&gt;
  &lt;/object&gt;
  
  &lt;script language="javascript"&gt;
      app.helloWorld();
  &lt;/script&gt;
  </code></pre>
  
  <p>Help is greatly appreciated.</p>