简体   繁体   中英

How to run an plain java app on Websphere

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

It's a bit hacky, but I'd be tempted to add a line to startServer.{bat|sh} to start your Java program. Eg (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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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