- Lab 0 Home
- Warmup
- Part 1
- Part 2
- Part 3
- Submission
Part 3 - Doing “real work” in Eclipse
Create project
Now we should create a project in our lab0 folder like you'll be doing in many of the labs.
- Select “File” > “New” > “Java Project”
- Call it “Hello 151” (or “lab0” or whatever you want)
- uncheck the box for “use default location”
- Use the “Browse” button to select the lab0 folder you created earlier
- Now just select “Finish”
If you want, you can close the Task List and Outline panes on the right side. We won't be using them for this.
Now let's create a class that will tell the user a little bit about yourself.
- Select “File” > “New” > “Class”
- Don’t change the project or source folder
- Set the Name of class to be Hello151
- Check the box that will create the main method stub
- Now select “Finish”
You should now see Hello151.java in the Package Explorer window. If you do an ls on the command line in your lab0 folder, you'll see that there is both Hello151.java and Hello151.class in this folder. Eclipse compiles as you work!
Comments!
The Hello151.java file should be open in the editor. If not, just double click on it in the Package Explorer window. Let's add some comments to the top of the file.
- Go to the top of the file and start a Javadoc comment. Recall they begin with /**
- Put in a short description of what this file is supposed to do. In this case, you are going to introduce yourself to the graders.
- On another line, but still in the comment block, start a line with @author followed by your name
- Close the comment block with a */. It is likely that eclipse has already done this for you.
Run your program
Just in case you've not actually tried to run your program, now would be a great time to check that it works. Here's a line you can add to the main method that will give you some output
System.out.println("When I graduate, I will donate 10% of my salary to the CS department.");
You can run it in Eclipse by just selecting "Run", "Run" from the pull-down menus. Or right-click and select "Run As", "Java Application".
Share with the graders
Now let's add some print statements to introduce yourself to the graders. Inside the main() method, add in a number of System.out.println messages that will share:
- Your name as you want to be called
- Your CS username
- Your year/major (if known)
- Something you think is awesome about Oberlin
Get on with your life
If you've made it this far, and actually changed preferences and done the steps I listed above, that's enough Java programming for this week.