Overview
This assignment introduces the Eclipse Integrated Development Environment and a basic Java program.
- Setup the Eclipse IDE
- Create a new Eclipse Project
- Create a new Java Class
- Comment your Java file
- Prepare and submit the assignment on Sakai
LEGEND: Keyboard Screen
Task 1: Create a new Eclipse Java project titled Chapter1
- File | All Programs | Computer Classes | Eclipse 3.3
- You will likely be asked to define a "Workspace" -- which is simply a place to store your files and settings. Use the eclipse directory you created in Lab 0, which should be at k:\cosc181\eclipse\
- File | New | Java Project
- Type Chapter1 as the Project Name
- click Finish
Task 2: Create a Java main class titled HelloWorld within project Chapter1
- Highlight Chapter1 in the Project Explorer along the left
- File | New | Class
- Make sure Source folder is Chapter1/src
- For Name type HelloWorld (just like that -- no space, uppercase 'H' and 'W')
- check the box next to public static void main(String[] args)
- click Finish
Task 3: Add code to HelloWorld to make it display "Hello World!"
- Place the cursor at the end of the line that reads //TODO Auto-generated method stub
- Hit Return, then type System.out.println("Hello World!");
- File | Save
- Run | Run
- Along the bottom, you should see a "Console" tab with the output "Hello World!"
Task 4: Add a standard class header comment to HelloWorld.java
- Copy and paste the following lines before the line that starts public class HelloWorld {
- Change the author to your name and the date to today's date
/**
* HelloWorld displays a generic message to the console.
*
* @author Gene Rohrbaugh
* @version 1.0 8/29/2009
*
*/
Task 5: Take a screen shot of a successful run of your program
- Run the program ( Run | Run ), then take a screenshot of the Eclipse window ( Alt-PrntScrn ) , then save it as k:\cosc181\lab\lab11_lastname\HelloWorld.jpg
Task 6: Copy your java source file into the submission directory
-
go to k:\cosc181\eclipse\Chapter1\src\
right click on the Java source file HelloWorld.java and select Copy (alternatively, you could select the file and type ctrl+c to copy)
-
go to k:\cosc181\labs\lab01_lastname and paste ( Right-click | Paste or Edit | Paste )
- The directory should now contain two files: HelloWorld.jpg and HelloWorld.java.
Task 7: Prepare and submit your lab
- Virus-scan the folder containing your files ( lab11_lastname )
- Compress the folder to a zip file named lab11_lastname.zip
- Upload the zipped directory to Sakai
- Submit the assignment
Challenge Problem
-
Based on your HelloWorld program, make a program that displays a custom message, such as:
Hello Gene!
You are an awesome Java programmer! - Your program should be named HelloName, where Name is your own name.
- Make sure you change the header comment to reflect the new purpose.
- Submit a single, zipped, virus-checked folder containing a screenshot of a successful run (HelloName.jpg) and a copy of the HelloName.java source file.
