• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

main method

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how many methods can one project have
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too vague.
It really depends on the project.
Some projects won't have any main method at all (applets, servlets, common library, etc.).
Please be more specific.
 
corey williams
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a java application project
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to decipher your "java application" answer.
I've seen it on Eclipse.
Are you using Eclipse? Or any other IDE like NetBeans, IDEA, JBuilder, else?
What your java application will do?
If it's a program that will execute stand alone then you need only one starting point so only one main method.
 
corey williams
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm useing netbeans
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Corey --

Can you write a whole paragraph describing exactly what you're asking? Methods don't belong to projects; they belong to classes. A class can have any number of methods, but only one "main". A project is just an arbitrary collection of classes, and so it can have any number of "main" methods.
 
corey williams
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm sorry i didn't mean methods, i meant main class, how mian classes can you have in a project
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Before the days of unit testing tools like JUnit, lots of people wrote a main() in classes to run a few tests or examples. So they might have many, many classes with main methods. There is probably usually just one or very few that are really meant to start up the whole application.

It can get more complex as you reuse components and customize applications. I took a program that already had a main() and wrote another class to set up the environment and configure some things before calling the original main. So now it has two that do slightly different things.

Is that answering the right question?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by corey williams:
i'm sorry i didn't mean methods, i meant main class, how mian classes can you have in a project


As many as you like... If you start a Java program, you have to specify the class that contains the main method to the JVM. You can put any number of classes that contain a main method in your project. When you run the program, you'll just have to specify which one you want to use.
 
corey williams
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic