CSE 131 Module 0: Introduction

Lab


Which computer should use use for this lab sesesion?

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 this course, we'll be using eclipse, a popular IDE that supports (among many other things) 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 revision 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.

Attention wireless users in CEC labs!!

You must be on a non-guest network to access your repository. If your wireless network name has the word guest in it somewhere, switch to one tha does not.

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

  1. Start eclipse: 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:
    https://shell.cec.wustl.edu:8443/cse131_fl13/svn/YYYY
    After pasting:
    • Change YYYY to your WUSTL key, using lower case letters only. Include all punctuation that is normally part of your WUSTL key.

      If you would normally type in the WUSTL key shown on the left, you need to use the version shown in blue on the right to access your repository: Examples:

      • RonKCytron → ronkcytron
      • ima.StudeNt → ima.student
      • Queen.Mary.4 → queen.mary.4

      Although only you can access your repository, you should generally keep your WUSTL key a secret.

    • OK, click Finish to get the repository location validated.
    • When you are prompted for a username and password, supply your
      • WUSTL key username (again, all letters must be lower-case)
      • WUSTL key password
      Your WUSTL key username and password are what you use to log into WebSTAC for registration. These credentials may be different than those required to log into a lab computer.

      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 labs.

  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:
    1. In the Package Explorer, expand 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 labs, which is a folder that contains packages of code.
      Throughout the semester, this is where you should look for the files you need to complete your assignments.

      Supporting software is placed in other source folders, such as labsupport. You are welcome to look at any code, but to keep the number of files managable, we'll place lab code in your labs source folder in your repository.

    2. Expand the labs folder (click on its '+' sign or triangle).
    3. Each lab you complete is given to you in a separate package. For this lab, expand the lab0 package.
    4. 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.
      If what you see makes sense to you already, you may not need to take this class.
      For now, you don't need to understand what you see. We just want the computer to run this program.

  6. Run the program: Right click on RobotController.java and select Run as -> Java application. In the bottom right corner, you will see a GO button. Click the Go . The program should create a robot, and you should see the robot start to move.

  7. Modifying 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 into the RobotController.java 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.

    Undo your typing, or close (without saving) and re-open the file.

  8. Make the robot do your bidding: So your real assignment here is to provide some instructions so that the robot navigates from from CEC to your instructor's office.
    1. Open up the RobotInstructions file, which is also in your lab0 package. This is where the commands to move the robot are written.
      You now have two files open in eclipse:
      • RobotController.java is the main file. You always run the application using the instructions given above for this file.
      • RobotInstructions.java is the file that contains code directing the robot to move. This is the file you will modify to change the robot's behavior.
    2. Modify some of the robot instructions, and re-run the program, to gain an understanding of how the instructions in this file affect the robot's behavior.
      Really? We're asking you to program even though you probably don't much about Java yet?

      Well, yes.

      Even after you have learned much about Java, programming, and computer science, you may come across some code that you want to modify to change its behavior. This takes some courage, but see if you can figure out what the robot's instructions do, based on observing the robot and reading the code. Make some changes to the code to test your hypotheses. Soon you will have the robot doing your bidding.

    3. Once you have the hang of it, try to have the robot make its way from CEC to the instructor's office.
      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.
    4. 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 the the instructor's office to say hello sometime. Visitors are usually treated to soda and candy.

  9. Commit your work: 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 won't be visible by TAs or the instructor until you commit them.

    To commit them, locate the name of your project (your name and ID) in the package explorer window of eclipse. Right (control) click on that, go down to Team... and select Commit. You should see activity reflective of elipse sending your modified code back to the repository.

    Tip: It is good practice to commit your code often. You can always recover any previously committed version of your software. Committing your code allows you to work on the code from a different computer, and ensures that you do not lose your work should your computer fail.

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: Anatomy of a Java File, Overview of the Course

OK so you can program a robot now to go where you want it to go. How does this fit into the rest of the course? Based on the instructor's presentation, you will next complete a simple online activity (in pairs if you like), with the goal of understanding the anatomy of a Java file.

The course will then proceed from the most simple aspects of programming in Java to the more complex parts.


Part III: Install the course software

Windows users, a note before you try this: On Windows, we have seen problems when you try to place our course software where all of your other software lives. We suggest putting the eclipse folder in your home directory or on your desktop. For some reason, Windows imposes some restrictions on files placed where the other software lives, and that causes eclipse not to work so well.
If you have your own computer, portable or otherwise, you will find that the software runs faster and more conveniently on your own computer. Therefore, we recommend installing the course software by following the installation instructions.
TAs can assist you with this once you've completed the other parts of this lab. You can also try this on your own, outside of lab.


Part IV: Course Information

Take some time to peruse the web site. Are you clear about course policies concerning grading and attendance?


Make sure your work is committed before asking the TA to check you off


Submitting your work (read carefully)



Last modified 08:59:37 CST 09 January 2015
When you done with this lab, you must be cleared by the TA to receive credit.

Last name WUSTL Key Propagate?
(or your numeric ID) Do not propagate
e.g. Smith j.smith
1 Copy from 1 to all others
2 Copy from 2 to all others

TA: Password: