a very noob question. Can I run a .j开发者_StackOverflow中文版ar 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
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.
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.
I think what you want is Java's webstart
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/
精彩评论