Can I run .jar file on Tomcat?

后端 未结 4 1261
不思量自难忘°
不思量自难忘° 2021-02-14 04:08

a very noob question. Can I run a .jar file on Tomcat. I am not building a web-app. I simply need to run a .jar with say HalloWorld in it. Is this possible/appropriate.

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 04:39

    It sounds like want you want to do is deploy batch code to your server and then run it. You could either create a new web-app that contains your jar, or add the jar to an existing web app. Then you can trigger execution with a servlet. You could even have a JSP that contains:

    <%
      String [] args = new String[0];
      MyClass.main(args);
    %>
    

    Of course you'd want to secure that JSP so that not just anyone can run your job.

    We use the quartz scheduler to schedule batch jobs from within tomcat. This let's us monitor our jobs much more easily than if they were run from the command line.

    http://www.quartz-scheduler.org/

提交回复
热议问题