I want to call a java method getMessage() from a jar file whenever I click button on my webpage. I want to know how to achieve this.
My html file : index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<script src="jquery-1.11.1.min.js"></script>
<script language="javascript">
function openMsg()
{
var request = $.ajax({ // Here I am just calling jar file but I want the code to call method getMessage();
url: "Example.jar",
type:"GET",
dataType:"html"
});
request.done(function(msg){
$("print").html(msg);
});
request.fail(function(jqXHR, textStatus){
alert("Request failed :",textStatus);
});
}
</script>
</head>
<body>
<button onclick="openMsg();">Click to open message</button>
<p id="print"></p>
</body>
</html>
My java file : Example.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JApplet;
public class Example extends JApplet
{
public void start()
{
}
public void init()
{
setBackground(Color.blue);
}
public void paint(Graphics g)
{
g.drawString("Hello World !", 100, 100);
}
public void getMessage()
{
System.out.println("Good Morning..!!!");
}
}
Please someone tell me how can I call getMessage() method from Example.jar