• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Main() Class

 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
just curious.....How many Main() classes can you have in the application?
I have 2 Main() executable Classes.
Thanks,
Sri
 
Junilu Lacar
Bartender
Posts: 7600
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As many as you want. In fact, all your classes can have main() methods if you so desire(although I don't think it would earn you any points for clarity). The main() method executed will be that of the class you specify on the command line when you start java.
Junilu
 
Junilu Lacar
Bartender
Posts: 7600
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to Java in General (beginner)
------
(Re-opened) I may have been too quick to close this topic as it seems to be related to how you're doing the programming assignment. Sorry about that, Sri.
------
Why do you have two main()s?
From what I have personally observed, the main reason for having more than one main() is to use it as a quick and dirty way to do unit testing. If this is true in your case, I suggest that you try using the JUnit framework to write unit test code so you can keep your test code separate from production code.
Junilu
[ May 28, 2002: Message edited by: Junilu Lacar ]
 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Junilu Lacar:
Moving this to Java in General (beginner)
------
(Re-opened) I may have been too quick to close this topic as it seems to be related to how you're doing the programming assignment. Sorry about that, Sri.
------
Thanks! I appreciate your help!
Actually i think even the way i posted my question was wrong. Which might have made you think so. Sorry about that.
Why do you have two main()s?
From what I have personally observed, the main reason for having more than one main() is to use it as a quick and dirty way to do unit testing. If this is true in your case, I suggest that you try using the JUnit framework to write unit test code so you can keep your test code separate from production code.
Junilu
[ May 28, 2002: Message edited by: Junilu Lacar ]

The reason for having 2 Main() methods is that,
The first is to execute RMIDataServer
and the second one is to run the GUI/client application.
I thought this is the way i could do, to the best of my efforts. I am not sure if its dirty testing or not.
But can anyone please guide me, if there's any other way to execute both the RMIDataServer and the Client application is one/single command line option, with a single executable class in the entire application?
or am i going wrong here?
And i haven't used any IDE for development, i was only using Textpad.
Mark, can you please help me....
Thanks,
Sri
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, Sri, yes you need to have two main classes, one for the server and one for a client.
But think of them as two different applications. The server is to startup the server, and will be run by the "Server Admin", whereas the client is a seperate program that the clients have. The clients in remote mode really don't knwo that there is some server running out there. That is why you can think of them as two seperate.
So you don't want a way to run one program that will start both.
Mark
 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Mark thanks alot.
Now i understand, its much clearer now.
Thanks again,
Also Mark i have a couple of questions regarding design patterns too. As you said i'll write down my architecture, with all classes and interfaces, in my next post. And also how did you get to draw the UML so well. It really imprest me...
Can you please help me on that too...
I really appreciate all your help.
Sincerely,
Sri
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also how did you get to draw the UML so well

Really where did I do this? The only sort of UML I created was in text format, and took too long for really not needing it anyway.
Just work on lots of - signs and hope things line up.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic