Can I run .jar file on Tomcat?

后端 未结 4 1263
不思量自难忘°
不思量自难忘° 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:14

    You can run a Java archive without Tomcat, simply with a Java Runtime Environment:

    $ java -jar myhelloworldapp.jar
    

    Tomcat is a servlet container, only needed for web applications.

    0 讨论(0)
  • 2021-02-14 04:19

    I think what you want is Java's webstart

    0 讨论(0)
  • 2021-02-14 04:37

    I don't really know what your use case is, but what you probably need is a virtual private server (VPS) provider. They give you a virtual host which runs OS of your choice and you can install JVM on it. There are many VPS' available. Try Linode or Slicehost.

    It would help if you would explain what you are trying to achieve, then we might be able to give you a better answer.

    0 讨论(0)
  • 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/

    0 讨论(0)
提交回复
热议问题