如何在 Websphere 上运行普通 Java 应用程序

发布于 2025-01-01 10:37:37 字数 103 浏览 3 评论 0原文

我有一个独立的java应用程序,它有一个主类。我想在 Wepsphere 启动时运行这个课程。我不想为此使用 servlet。 我如何使用管理控制台/脚本等来做到这一点?

谢谢

I have a standalone java application which has one main class. I want to run this class when Wepsphere starts up. I don't want to use servlet for this.
How can I do this using admin console/scripting etc?

Thanks

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

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

发布评论

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

评论(1

千秋岁 2025-01-08 10:37:37

这有点 hacky,但我很想在 startServer.{bat|sh} 中添加一行来启动 Java 程序。例如(在 Windows 上):

start "Thrift" /D<working directory> java -cp <classpath> com.thrift.Main

如果您需要在 Websphere 关闭时再次停止程序,您可能还需要编辑 stopServer.{bat|sh}

或者... (最好)

创建一个启动您的应用程序和 Websphere 的新脚本,然后运行该脚本:

start "Websphere" /D<was-working-dir> startServer.bat
start "Thrift" /D<thrift-working-dir> java -cp <classpath> com.thrift.Main

优点是您最终不必编辑Websphere 脚本,因此您不会受到未来 WAS 补丁可能应用的任何更改的影响。但是,如果 WAS 作为服务启动,那么您可能需要更改正在运行的命令以指向新脚本。与本答案的其余大部分内容一样,如何执行此操作取决于您的平台。

It's a bit hacky, but I'd be tempted to add a line to startServer.{bat|sh} to start your Java program. E.g. (on Windows):

start "Thrift" /D<working directory> java -cp <classpath> com.thrift.Main

If you need to stop the program again when Websphere is shut down, you might want to edit stopServer.{bat|sh} as well.

Alternatively... (and preferably)

Create a new script that starts both your app and Websphere, and run that instead:

start "Websphere" /D<was-working-dir> startServer.bat
start "Thrift" /D<thrift-working-dir> java -cp <classpath> com.thrift.Main

Advantage is that you don't end up editing the Websphere scripts, so you won't be affected by any changes that future WAS patches might apply. However, if WAS is being started as a service, then you might need to alter the command that's being run to point to your new script instead. As with most of the rest of this answer, how to do this differs depending on your platform.

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