*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Main() Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Main() Class" Watch "Main() Class" New topic
Author

Main() Class

Sri Addanki
Ranch Hand

Joined: Apr 27, 2001
Posts: 195
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

Joined: Feb 26, 2001
Posts: 4442
    
    5

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

Joined: Feb 26, 2001
Posts: 4442
    
    5

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

Joined: Apr 27, 2001
Posts: 195
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sri Addanki
Ranch Hand

Joined: Apr 27, 2001
Posts: 195
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Main() Class
 
Similar Threads
main in multiple classes
regarding top level classes
NEED HELP IN BASIC JDBC
Why a non-abstract Parent Class can be extended by an abstract Child Class ?
Main() Class