This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I think you're making it too difficult for yourself
I shall explain how I did it:
- I have a client class and a server class, they have public constructors. There is NO main method in neither one of them - I have a class called StartUp that only has 1 method: main()
That main method read the parameters the user gave in during the "java -jar runme.jar" procedure
StartUp.main() looks at the flag: - is it SERVER, a new server object is created - is it ALONE, a new client object is created and will start immediatly in standalone mode (I pass true or false in the client constructor so it knows which mode to run) - is it empty, a new client object is created and will show my connection panel, which allows the user to go in local or in network mode
So my the manifest in my jar points to the startup class ... and that's it, you're done.
If you start it up, it will start client or server, depending on the flag you give. So by default the client is started.
SCJP 1.4 (90%)<br />SCJD (in progress)
Joined: Feb 16, 2006
Kristof - thx.
I am a finance guy trying to learn java. A whole new world.
I need to study design patterns and such. Just purchased the Head First Design Patterns. [ March 21, 2006: Message edited by: tom smith ]
StartUp.main() looks at the flag: [...] - is it empty, a new client object is created and will show my connection panel, which allows the user to go in local or in network mode
I do not think this is correct. At least according to my specificiation, when no argument is specified the client needs to run in networked mode - you should not allow the networked/alone choice at this stage.
Tomasz Luchowski<br />SCJP, SCBCD, SCWCD, SCEA part 1