Intro | Perspectives | Projects | Tips&Tricks | UML
Create the main file for the tutorial project
If the tutorial project is not listed in the Package explorer (left panel), go back to the previous subtopic to review how to import the project into the workspace. If the project is listed in explorer but is not open, right click on tutorial and choose Open Project. Now do the following -
Eclipse will create the code for TutMain and open the file in the editor. You will notice that Eclipse also includes comments - you should edit the comments by deleting the two sets of double comment lines that begin with * To change the template for ... This is a note to the user that the template used for creating the default comments can be changed. If you are using your personal copy of Eclipse, you may want to change the indicated template at some point. (If so, leave the comments as they are to remind you.)
The code should look something like the following:
public class TutMain {
public static void main(String[] args) { } }
Note: if you forgot to check public static void main(String[] args) when defining the class, you can either type in the missing code or, in Package explorer, right click TutMain and choose delete. Then start over with item #1 above.
Place your cursor at the end of the public static void main ... { line and press RETURN. This opens up the main block. Type the following inside main():
public class TutMain {
public static void main(String[] args) { System.out.println("Tutorial"); // <-- type this line, don't forget ";" at end } }
You will notice that if you type slowly, Eclipse pops up a window from which you can choose an item to complete the line. Also, when you type the first parenthesis, Eclipse completes the closing parenthesis as well. You will find this type of "smart completion" occuring often as you enter code.
At this point you have completed the project. Now go to the next subtopic to run your program.