I'm writing a server in Java. To support the development of the server, I have a few classes with main() methods that I intend to run from a command line as development tools to do such things as diagnostics, simulate client connections and exercise modules in isolation from the rest of the server. Currently, these classes are part of the main server project.
What's the best approach for structuring my project to support these multiple executable tools? Should I create separate projects for these simulation / loading / diagnostic tools, or keep them in the main server project? If I keep them in the main project, should I configure the project to build multiple executable jars or a single jar with multiple entry points? If a single jar is used, would it be possible to specify the primary entry point for the server as the default?
Unless the server and the utilities have completely different dependencies, I would make it simple, and put everything in a single jar. Provide shell scripts which wrap the calls to the appropriate classes:
# startServer.cmd
java -cp MyServer.jar;other.jar com.foo.myserver.Main
#showDiagniostics.cmd
java -cp MyServer.jar;other.jar com.foo.myserver.Diagnostics
You can make it an executable jar with the server startup class as the main class, but I find it easier to have an executable script than to have to use java -jar MyServer.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With