CSSE 220: Object-Oriented Software Development
HelloWorld

Work on this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.

Goals

The goals of this exercise are to:

The Exercise - Overview

You will:

Instructions

    Stage 1 — Create a New Project

  1. If you have not already done so, create a folder for your Java Projects for this course.

  2. Open Eclipse and make sure that Package Explorer is visible in the left window.
  3. Just this once, confirm that you are in the workspace for your Java Projects, by doing:
    	File → Switch Workspace → Other
    
    and browsing to the folder you created for your Java Projects for this course.

  4. From the menus, select File → New → Java Project. This will bring up the New Java Project Wizard.
  5. Name your project HelloWorld (no spaces, capitalized just as written). Accept the defaults, but notice that you are choosing to Create a New Project in Workspace.
  6. Choose Finish and you should be back at the Package Explorer. Expand HelloWorld and notice what is different now in Package Explorer.
  7. Stage 2 — Create a class with a main function

  8. Create a class with a main function by:

    1. Highlight the src folder in the Package Explorer and right-click to create a New → Class
    2. Name the class HelloPrinter (no spaces, capitalized just as written)
    3. In creating the new class, select the option to put a main method in your class.
  9. Just for practice, delete your newly-created class (right-click on it and ...) and then recreate it.
  10. Stage 3 — Make your program print Hello, World and run your program

  11. Write the code for printing Hello, World inside main:
        System.out.println("Hello, World");
    
  12. Run your program by selecting in Package Explorer the .java file containing main, right-clicking, and choosing Run as → Java application.
  13. Run the program again, this time using the Run button on the toolbar.
  14. Minimize Eclipse and go find the folders for HelloWorld, bin and src. Unless you redirect your project workspace output, from now on all your projects will be created here.
  15. Stage 4 — Add the project to Version Control

    This step shows you how to put your project under version control; then next stage will show you how to commit updates to the project.

  16. Right click on the HelloWorld project in Package Explorer, and choose Team → Share Project
  17. If asked, select SVN (not CVS -- Eclipse supports both version control systems, but SVN is the more modern one; Eclipse will remember the choice you make now) and select Next
  18. If given a choice, select Create New Repository Location and select Next.
  19. You have a personal repository for this class:
    	http://svn.cs.rose-hulman.edu/repos/csse220-200930-mutchler
    
    where you replace mutchler in the above with your own Kerberos username.

    In the Share Project dialog that you are now in, type the above (with your own username) as your URL. Then choose Next.

  20. Accept the default to Use project name as folder name, and select Next.
  21. You are offered an opportunity to put a commit comment. The default (Initial commit) is appropriate here.
  22. Eclipse may ask you your SVN password. If you don't know it or have forgotten it, ask your instructor to set it for you now.

    After you choose Finish you should see log file notes in the Eclipse console window that verify your success. If not, get help now.

  23. If you are in the Repository perspective, return to the Java perspective by using the tab in the upper-right corner of Eclipse.
  24. Stage 5 — Modify the project, then Commit the changes to Version Control

  25. Add another statement to main that prints Goodbye, World.
  26. Commit your changes to the repository by right-clicking on the HelloWorld project in Package Explorer and choose Team → Commit.
  27. Stage 6 — Learn how to fix errors in your program

  28. Make an error in your program. Then ask someone near you to use your keyboard and fix the error.
  29. Stage 7 — Add a method to your program that uses a loop

  30. Add to your program a method that takes an integer n and prints Hello, World n times, each on its own line. Call the method from main, sending it 36 (so that 36 greetings are printed on the console).
  31. Stage 8 — Make your program use good style

  32. In all your code throughout this term, fill in the Javadoc comments appropriately, at each of the places where the comment says TODO.
  33. In all your code throughout this term, use explanatory variable and method names.
  34. In all your code throughout this term, type Control-Shift-F before you turn it in (and occasionally throughout your coding).
  35. Stage 9 — Commit the final version of this program to your repository

  36. Commit your changes to the repository by right-clicking on the HelloWorld project in Package Explorer and choose Team → Commit.