Matt Kidd wrote:
David Newton wrote:You're going to have to be more specific; normally a project would only have a single main.
If you have a project with many main methods, create new configs rather than changing the existing one.
*sigh*
okay. To be specific, the reason I have so many main methods is because I'm working through a book learning a new api and coding the examples. It's tedious but if this is the only way so be it.
Actually, it's not that uncommon for a project to have multiple main methods. I know a number of people who set up projects with
test code and it's run by running the class under test as a main class. Although
JUnit is what I recommend - it allows better management of tests and provides a better supporting framework.
Eclipse is based on the concept of a Project. A Project doesn't
have to be a directory inside an Eclipse workspace, but that's a convenient (and default) place to put them. Technically, the Project is a set of project definition files + workspace metadata, but we usually consider the directory containing the actual code and supporting files to be the "real" project. In order to keep things manageable, each Eclipse project must have a single root directory, although projects may "borrow" resources from other projects.
When an Eclipse project has been defined as a Java project, one or more directories are designated as Java Source Code directories, and one or more directories as compiled class directories. This can be adjusting using the Project Properties editor. Whenever you save changes to a Java Source Code file, it's automatically recompiled (unless you switch off that option) and the resulting class file gets placed under that source file's corresponding output class directory.
Running apps and debug sessions is actually done in a separate subsystem. You define a Run profile and specify not only the Main class, but any other environmental options you might need, such as classpath extensions, command-line options and so forth. It's really just the GUI equivalent of setting up batch execution files. You can set up as many different run profiles as you want (the same profiles can be used for both run and debug). It's also permissible to set up more than one profile for a given class. For example, if you want to test using a different set of run command-line options.
Run profiles also apply to other environments besides stand-alone Java applications, but the details vary, based on the environment. For example, the
Applet run profiles invoke an Applet Runner.