A Structure project for Java with a few basic entry points and executables?

I am writing a server in Java. To support server development, I have several classes with main () methods that I intend to run from the command line as development tools to perform tasks such as diagnostics, simulate client connections and exercise modules in isolation from the rest of the server. These classes are currently part of the main server project.

What is the best approach to structure my project to support these few executable tools? Should I create separate projects for these modeling / loading / diagnostic tools or store them in the main server project? If I save them in the main project, should I configure the project to create several executable jars or one jar with several entry points? If one bank is used, is it possible to specify the main entry point for the server by default?

+4
source share
1 answer

If the server and utilities do not have completely different dependencies, I would simplify them and put everything in one jar. Provide shell scripts that transfer 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 bank with the server startup class as the main class, but it’s easier for me to get the script executable than using java -jar MyServer.jar

+8
source

Source: https://habr.com/ru/post/1390681/


All Articles