Can I run .jar file on Tomcat?

China☆狼群 提交于 2019-12-04 20:27:43

问题


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.

Thanks


回答1:


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.




回答2:


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.




回答3:


I think what you want is Java's webstart




回答4:


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/



来源:https://stackoverflow.com/questions/4588293/can-i-run-jar-file-on-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!