Search code examples
javaeclipseprogram-entry-point

Can I have more than one class containing the main() method in a Java project?


In a Java project (handled by Eclipse for example), can I have more classes that contain the main() method and consequently can I chose to execute one class over another class?


Solution

  • Yes, you can have more classes that contain the main() method, but at least one class which contain main() should be public so that JMV will start that class as Main thread

    • as the code written by aUserHimself represent