Calling Java class from JavaScript without servers

I have a java class and I want to access the same class in HTML page using JavaScript. I want to know what are the possible ways of achieving this.

1 answer

  • answered 2018-05-16 05:50 Hello World

    Convert your Java Class into Servlet and using Ajax hit the servlet and do the required tasks. look into this http://hmkcode.com/java-servlet-send-receive-json-using-jquery-ajax/ for a starter.

    You can either use a servet engine like tomcat, and write a servlet that will serve your JSON document, or use the com.sun.net.httpserver.* classes that is in the JRE.