HelloWorld
Work on this exercise by yourself,
but ask questions of your instructor, student assistants and classmates as desired.
Goals
The goals of this exercise are to:
- Familiarize you with our development environment (Eclipse)
- Ensure that you can create a simple program from scratch
- Introduce you to creating a new project using Version Control from within Eclipse (i.e., using Subclipse)
The Exercise
You will design, implement and test the famous HelloWorld program.
You will add the HelloWorld project to a central repository using Subclipse.
This is an exercise that screams for questions -- ask them when they arise!!!
Instructions Part 0 - Install Subclipse
Install Subclipse, if you haven't, by following the instructions at
http://www.rose-hulman.edu/class/csse/resources/Subclipse/installation.htm
Instructions Part 1 - Create the Project
- Open Eclipse, and make sure the Package Explorer is visible in the left window.
- From the menus, select File → New → Project. This will bring up the New Project Wizard.
- Accept the default choice, Java Project and choose Next.
- 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.
- If you don't know what a workspace is, now is the time to find out.
- Choose Next, and notice the folders (src and bin) that Eclipse is about to create for you
- If you don't know what the src and bin folders are for, now is the time to find out
- Choose Finish and you should be back at the Package Explorer.
- What is different now? (observe, don't write)
Before you continue, 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.
Instructions Part 2 - Write and Execute the Code
- Write the code for HelloWorld....
- Hint: Start by highlighting the src folder in the Package Explorer,
and right-click to create a New → Class
- Hint: In creating the new class, select the option to put a main method in your class.
- Note: You should create only one class with only one method in this project.
- Make sure it runs as a proper dignified HelloWorld program should, with output on the console - no GUIs.
To run, select in the Package Explorer the .java file containing main(),
right-click, and choose Run as → Java application.
(Or, find the Run button on the toolbar.)
- After making it print Hello, world (or something like that) once,
write a loop to make it print Hello, world 300 times.
- Optional: make each iteration display the iteration number, e.g.
1 Hello, world
2 Hello, world
3 Hello, world
and so forth.
- Fill in the Javadoc comments appropriately.
Then choose Project → Generate Javadoc... to generate the HTML Javadoc comments.
Examine the comments -- pretty cool, yes?
Instructions Part 3 - Add the Project to Version Control
- Right click on the HelloWorld project in Package Explorer, and choose Team → Share Project
- Select SVN (not CVS -- Eclipse supports both version control systems, but SVN is the more modern one)
and select Next
- Select Create New Repository Location and select Next
- You may not get this option dialog the first time you use Subclipse,
because you have not told Eclipse about any existing repository locations yet.
- Type as the URL
http://svn.csse.rose-hulman.edu/repos/csse221-201110-YOUR_USERNAME
where you replace YOUR_USERNAME by your Kerberos (and Subversion) username.
Then choose Next.
- Type carefully! Case matters. No spaces.
- Accept the default to Use project name as folder name, and select Next.
- Include a useful comment that describes the current state of your HelloWorld project.
If it's done, say so. This is important for later on!!!!
- After you choose Finish you should see log file notes in the Eclipse console window that verify your success.
Now it has committed the project, but not your file.
- If it asks you about the Synchronize view, select Remember my decision
and No.
- Now right-click on your HelloWorld project again, and choose Team →
Commit to commit your files to the repository.
- Minimize or exit Eclipse and go look for your HelloWorld folder.
Something is very different - a Green Check mark is on the folder,
indicating that the folder and its contents are now part of the version control system.
From now on, when you want to modify this project, you will need to update your local copy first,
in case anyone else has worked on the project.
Then, after you make your changes,
you will commit your changes back to the repository so other people can see them.
- All these actions start by
right-clicking on the HelloWorld project in Package Explorer
and choosing Team → ....