简体   繁体   English

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

[英]How to run an plain java app on Websphere

I have a standalone java application which has one main class. 我有一个独立的java应用程序,它有一个主类。 I want to run this class when Wepsphere starts up. 我想在Wepsphere启动时运行这个类。 I don't want to use servlet for this. 我不想为此使用servlet。 How can I do this using admin console/scripting etc? 如何使用管理控制台/脚本等执行此操作?

Thanks 谢谢

It's a bit hacky, but I'd be tempted to add a line to startServer.{bat|sh} to start your Java program. 这有点hacky,但我很想在startServer.{bat|sh}添加一行来启动你的Java程序。 Eg (on Windows): 例如(在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. 如果在关闭Websphere时需要再次停止程序,则可能还需要编辑stopServer.{bat|sh}

Alternatively... (and preferably) 或者...... (最好)

Create a new script that starts both your app and Websphere, and run that instead: 创建一个启动应用程序和Websphere的新脚本,然后运行该脚本:

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. 优点是您不会最终编辑Websphere脚本,因此您不会受到未来WAS补丁可能应用的任何更改的影响。 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. 但是,如果WAS作为服务启动,那么您可能需要更改正在运行的命令以指向新脚本。 As with most of the rest of this answer, how to do this differs depending on your platform. 与此答案的大部分内容一样,如何执行此操作会因您的平台而异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM