0

My idea is to make a chat program using SWING. So I will have 1 class Server which will use no GUI and 1 class Client with GUI( the Client will be run a couple of times ).

How should I structure my project ( is it a good idea to use 1 project for both or separate projects? ), because I need to run the server as a standalone jar therefore it will need a main method, and also the Client will need to be run like a standalone jar, but I can not have 2 classes with main method in them?

CuriousGuy
  • 1,545
  • 3
  • 20
  • 42
  • Please clarify, if both (client and server) are contained in a single jar. If so, [this link](http://stackoverflow.com/questions/3976514/multiple-runnable-classes-inside-jar-how-to-run-them) may provide helpful information. – Stefan Freitag Aug 11 '15 at 18:50

1 Answers1

0

You can have multiple classes with main methods, but a better approach is to compile the common code once, then build separate jars which copy the common classes, each with its own main class. If you're using Maven or Ant it's straightforward to create the common code as a jar, and incorporate its contents into each of the application jars. In your case, the Swing code would appear only in the GUI jar, making the command-line jar smaller.

This is much easier to maintain than having two fully separate projects.