Turgut Tak
Turgut Tak

Reputation: 43

Running the JAR on public web

I have created a jar using eclipse. I want to put this jar on my website and want people to use this program over the internet.

Is there a way to make it easy or should I re-code the program as web service?

Upvotes: 0

Views: 59

Answers (3)

Atul Sharma
Atul Sharma

Reputation: 10645

<%@ page import="java.util.Arrays, com.jarpackage.jar" %>

<%
    String param= request.getParameter("paramName"); 

    //if any input is required from user

     JARClassName service= new JARClassName();
     String message = service.JarMethod(param);
     response.setStatus(200);   
     response.getWriter().write(message);
     //writing data back to output.

%>

You can write jsp like this , from where you can call method of your JAR and return the output to user.

You can use Get parameters and read using request.getParameter("paramName") if any input from user is required.

Upvotes: 0

grthr
grthr

Reputation: 96

The solution depends primarily on what your program (jar) does and how it is structured.

  • Is it a pure console application or does it offer a GUI?
  • Should the application run on the client or on a server in the future?

In the case of the console application, a web service that accepts requests with or without parameters would probably be the first choice. Then the application runs on the server.

If the application provides a GUI, Java Web Start is one way of using the existing interface unchanged, as already suggested. In this case, the application runs on the client. Alternatively, you could move the application's business core to a new web application that executes code both in the client's browser (JavaScript) and on the server (Java).

Upvotes: 1

pecks
pecks

Reputation: 340

yes it is possible, see Java Web Start: https://docs.oracle.com/javase/tutorial/deployment/webstart/index.html

Upvotes: 0

Related Questions