CS 150 - Spring 2018
Lab 2 - Java Introduction and the Start of P1
Wednesday, January 24, 2018
Objectives of this Lab
- Get Eclipse set up and running on your Linux account, and
- write a very simple Java program, followed by
- practice submitting your program to Checkin, and lastly
- learn about preliminary (and final) testing.
Using Eclipse
- To start Eclipse, open a terminal and type
eclipse.sh
, or navigate to the Eclipse icon under the Development section of your computer menu.
- You must do this every time you launch Eclipse.
- Close the window that welcomes you to Eclipse by clicking on the orange "Workbench" button.
- If necessary, select the (Window → Open Perspective → Java).
- You can change perspectives as need be to fit your workflow.
- If your perspective gets messed up, you can reset it by going to (Window → Reset Perspective).
- Create a default comment header with your name and other information by going to
(Window → Preferences → Java → Code Style → Code Templates → Code → New Java Files)
and putting a comment line for project name, your name, the class, the date, and your email as shown in the code below.
Starting the Assignment
Your TA will guide you in creating a project called P1 and class to begin the first programming assignment.
- Create a new Java project using the (File → New → Project) and name it P1.
- Right click on P1 in the Package Explorer tab and choose (New → Class).
- Each class in Java has an associated file of the same name.
- Have Eclipse add a main method to your program by checking the box next to
public static void main(String[] args)
.
- Name it "P1" (Eclipse will add ".java" automatically) and type the code shown below:
Your code should look like this, except with your name and email in the comments:
// Assignment: P1 Assignment
// Author: Russ Wakefield
// Date: 1/21/2018
// Class: CS150
// Email: Russ.Wakefield@colostate.edu
public class P1 {
public static void main(String[] args) {
System.out.println("Welcome to CS150!");
} // end main
} // end class P1
You can now run your program by clicking the green "Play" shaped button on the toolbar.
Please run your programs using the green play circle ("Run"), not the green circle within a square ("Launch").
Note that the output will appear in the Console window at the bottom or side of your Eclipse window.
You should see the program print a line of text to the console.
Submitting Your Program
Your TA will now walk through logging in to the course website, submitting your code, and viewing preliminary test results. Checkin is the website that allows you to submit programs and get them automatically graded. You should pass the first preliminary test. The TA will show you how to check the results of your preliminary and final testing, and how to retrieve your code from the Checkin tab. Read the assignment for P1. Now see if you can add another print statement and pass a second test. For detailed information on Eclipse, check out the Eclipse website.
- Log in to Canvas and open the Lab 2 attendance quiz on a department machine.
- Next, answer the first question of the quiz. Then, raise your hand
and show the TA your successful submission in Checkin.
© 2018 CS150 Colorado State University. All Rights Reserved.