This is how my java main class looks like
public class Main {
public static void main(String[] args) throws Exception {
XmlParser b = new XmlParser();
ServiceController sl = new ServiceController();
Pipeline2 objPipeline2 = new Pipeline2();
objPipeline2.main(args);
b.parseXML();
sl.callServiceByDomain();
}
public void function1() throws Exception {
System.out.println("hello");
}
Here is the run.jsp file where i want to run the main function
<%@ page import="java.io.*" %>
<%@ page import="main.Main" %>
<HTML>
<HEAD>
<TITLE>Enter Email over here</TITLE>
</HEAD>
<BODY>
<jsp:useBean id="link" scope="application" class = "main.Main" />
<%Main r=new Main();
Main.main(null);%>
</BODY>
</HTML>
I am not able to run it if i am running the run.jsp file where as if i am trying to run the function1 from the jsp in place of main....it is running. please help me in this regard
The main method accepts a parameter (String[] args). Try <%r.main(null);%> if you are not interested in passing any parameters.
BTW, main is static, so <%Main.main(null);%> should also work, and is the preferred way of calling a static method (i.e. without creating an instance of Main).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With