CSE 131 Module 0: Getting started

Lab


Notes:

Part I: Getting Started with Java in Eclipse with Subversion

Professional software developers use an Integrated Development Environment (IDE) that includes a text editor (for creating source code), a compiler (for translating source code into executable code), and a debugger (for finding errors). In CSE131, we'll be using eclipse, a popular IDE that supports programming in Java.

Professional software developers also use a versioning repository to store their code, so that they can share their code easily and keep track of the changes they make. We will be using the subversion revsion control system. It will allow you to submit your code for grading and to share it with TAs who can help you with problems you might encounter.

This part of the lab explains how to get started using Eclipse with subversion.

  1. Start Eclipse: In CEC, click on the Start button and look under "All Programs", "Programming" to start up eclipse 3.4. The first time Eclipse starts, it will be slower than usual. You will be asked where you want your workspace to be.
    We recommend using the default location, and checking the box so you won't be asked again.
    After Eclipse starts up, click the 'X' on the "Welcome" tab at the top to close the welcome screen.

  2. Identifying your repository: Open the subversive tutorial in another window, and follow the steps given there to specify a subversion repository.

    When you get to the point of entering the full and complete location of the repository, copy and paste the line below as the repository's URL:
    svn+ssh://XXXXX@grid.cec.wustl.edu/project/cec/class/cse131/fall09/students/YYYY-ZZZZZZ
    After pasting:
    • Change XXXXX to your username that you use to log into cec computers. For example, jdl2.
    • Change YYYY to your last name, exactly as it is shown in WebSTAC, with capital letters as shown, but without any quotes or spaces.

      Examples:

      • Smith → Smith
      • de Erausquin → deErausquin
      • O'Kelly → OKelly

    • Be sure the hyphen is still there, just after your last name and just before the ZZZZZZ.
    • Change ZZZZZZ to your student id number, all 6 digits.
      Please keep your ID number a secret! Your workspace is intended to be used by you alone at this point.

    OK, click Finish to get the repository location validated.

    Be careful! If you provide a bad password repeatedly, your account will get locked out after a small number of such attempts. So be sure to follow these instructions carefully and ask if things are not working.

  3. Continue following the rest of the instructions in the subversive tutorial so that you are back in the Java view and have the project available for your use.
    Those instructions next ask you to Check Out a copy of the repository location so you can do the work for this lab. Be sure to right click on the whole project (your name and ID number) to do the checkout. Do NOT click on things below that like src.

  4. Look at your project: If you are back in the Java view, then you should see a project in the Package Explorer at the left side of the Eclipse window. The name of the project is the hyphenation of your last name and your student ID number.

  5. Look at the source code: In the Package Explorer, open up the project by clicking on the '+' sign or little triangle to the left of the project name. You will see that it contains an entry for src, which is the source code for your project. Exand that too. In the source code you should find a package called lab0. Expand that too, and double-click the file named RobotController.java to open it. Look at the source code in the middle window. You'll see instance variables, methods, and a main method.

  6. Run the program: Right click on RobotController.java and select Run as -> Java application. You will see a map of some of the Engineering buildings. The program also provides a methods menu that contains a robot menu item. Select that menu item. The program should create a robot, and you should see the robot start to move.

  7. Compiling programs: In general, before you can execute a Java program, it must first be compiled (translated) into byte code that can be executed by the Java interpreter. A program that performs this translation is called a compiler. Eclipse checks your files to see if they will compile, and it marks errors so you can correct them. If you position the mouse cursor over an error icon or a red underline, a description of the error will be displayed.

    Try typing some random text in the file to introduce an error. You should see an error icon appear at the left. Note that sometimes the error message appears on the line after the error. At the bottom of the window, you'll see console and problems. The console window shows any printed output of the program. If you click on problems you'll see a list of the errors, and clicking on an item in the list will take you to the location of that error in the Java file so you can correct it.

  8. Make the robot do your bidding: Now that you have Eclipse set up for CSE131, your task in this assignment is to modify the provided program so that it will drive the robot from CEC to your instructor's office. For more details, read the comment in the RobotController file just before the run method. As you work on your program, you may want to write a few statements and watch the program run, just to make sure you are on the right track.
    Tip: Since RobotController.java was the program most recently run, you can run it again simply by clicking the green arrow on the toolbar at the top.
    Each time it runs, you should see the results of your most recent modifications.
    • If you pause with the mouse over a location on the map, the x,y coordinate of your mouse location will be shown on the screen. The RobotController file contains comments that talk about how to interpret the coordinates.
    • After 20 minutes of successful robot navigation, don't spend much more time trying to get the robot to go exactly the right way. Get comfortable with controlling it for a bit, and then you can have it plow through the walls, juggernaut style. That's a bit easier and a lot more fun.
    Also, feel free to walk the route yourself, and stop by my office to say hello sometime. I have soda and candy to give away to visitors.
    Now that you have modified a file, take a look at the Package Explorer window and you should see some > signs next to the files that have been changed. The > sign warns you that you have modified files that have not been committed back to the repository. The files will remain available on your CEC account, but they won't be visible by TAs or the instructor until you commit them.

You now know the basic steps to create projects, as well as open, edit, compile, and run Java programs in Eclipse. You should also have a basic understanding of sequential execution and how to call methods on ojects. Please ask if you have questions about any of this.

Part II: Electronic Orientation

The CSE131 web pages at will be an important reference in CSE131, so it's worth spending a few minutes to get familiar with the site.
  1. In Eclipse, open the provided file CSE131Trivia.txt. It contains questions that call your attention to a few administrative details you should know about CSE131.
  2. Using the Eclipse editor, fill in the answers to the questions using the information on the CSE131 web site.

Submitting your work:

Be sure you have committed your work back to the repository as follows:
  1. Right click on the project (your name-ID) in the Package Explorer
  2. Drag down to Team....Commit....
  3. You have to fill in some comment -- be creative.
  4. Click OK to cause your changes to be saved in the repository.
Your lab is not due until Tuesday, but we are set up today to demo it with you if you want to get that out of the way. It will only take a minute or so.

Follow the submission instructions to turn in your files and demonstrate your running program for a TA.


Submitting your work (read carefully)



Last modified 10:57:34 CDT 11 June 2012 by Ron K. Cytron