Is there a possibility to launch two different applications from the same jar? I’ve wrote simple client-server and both client and server parts are in one JAR. They use some common classes.
I understand, that I can create separate jars for client and for server and put commonly used classes and resources into the third jar. It’s actually the ‘correct’ way to do things. But my task is so simple and classes are so small that I just don’t want to make three jars instead of one.
java -jar requires Main-Class in the manifest. And it seems that I cannot make it work without -jar switch also.
BTW, client and server should be able to be running side by side of course.
You can always have two main classes in the jar and then use them depending on whether you want to run the client or the server, like:
and
you could even distribute bash or bat files to make running the different apps easier.