how do you compile in Eclipse? And how do you run the program using this given with the choice开发者_Python百科s: Java Applet or Java Application?
If Project -> Build Automatically is enabled, you will compile when saving your work.
To run it, you have an arrow in a green circle in your toolbar (6th tool if you have a default benchmark). It will run the project using the currently showing class as a main class if it has a main method, or the last run main if it doesn't. Alternatively, you can use the keyboard shortcut CTRL+F11.
If you click on the little down arrow next to the green button, you can access to a history of classes you ran and to the Run configuration, which allows you for example to run a program with parameters or, what interrests you here, to choose to run it as an applet or an application.
Turn on the option: Project > Build Automatically
If you have a main
method, run as Java Application. To create a main, type main
then ctrl+space and select "main method" to have eclipse auto create it for you.
精彩评论