我可以在 Tomcat 上运行 .jar 文件吗?

发布于 2024-10-10 07:53:58 字数 106 浏览 0 评论 0原文

一个非常菜鸟的问题。 我可以在 Tomcat 上运行 .jar 文件吗?我不是在构建网络应用程序。我只需要运行一个 .jar 在里面说 HalloWorld。这可能/合适吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

痴骨ら 2024-10-17 07:53:58

您可以在没有 Tomcat 的情况下运行 Java 存档,只需使用 Java 运行时环境即可:

$ java -jar myhelloworldapp.jar

Tomcat 是一个 servlet 容器,仅 Web 应用程序需要。

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.

总攻大人 2024-10-17 07:53:58

我真的不知道您的用例是什么,但您可能需要的是虚拟专用服务器(VPS)提供商。他们为您提供一个运行您选择的操作系统的虚拟主机,您可以在其上安装 JVM。有许多可用的 VPS。尝试 Linode 或 Slicehost。

如果您能解释一下您想要实现的目标,那将会有所帮助,那么我们也许可以给您更好的答案。

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.

や三分注定 2024-10-17 07:53:58

我认为你想要的是Java的 webstart

I think what you want is Java's webstart

挽你眉间 2024-10-17 07:53:58

听起来您想要做的是将批处理代码部署到您的服务器然后运行它。您可以创建一个包含您的 jar 的新 Web 应用程序,也可以将该 jar 添加到现有的 Web 应用程序中。然后您可以使用 servlet 触发执行。您甚至可以拥有一个包含以下内容的 JSP:

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

当然,您希望保护该 JSP,以便不只是任何人都可以运行您的作业。

我们使用quartz调度程序在tomcat中调度批处理作业。这让我们比从命令行运行作业更容易监视我们的作业。

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

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文