lab01 : Tools for java development

num ready? description assigned due
lab01 true Tools for java development Thu 09/29 04:00PM Wed 10/05 11:59PM

If you find typos or problems with the lab instructions, please report them on Piazza

Overview of this lab

Here is an overview of the remaining steps in the lab:

  1. If you didn’t already do it:
  2. Visit and login with your CSIL account, then logout immediately. This establishes your account. BUT WE WILL NOT USE THAT ACCOUNT FURTHER IN THIS LAB.

  3. Instead, login at After logging in, visit this link: You should have an invitation to join this organization. Please accept the invitation!

    If you do not, please ask your mentor to invite you to the UCSB-CS56-F16 organization on github.

  4. Now, create a private repo for lab01 under the UCSB-CS56-F16 organization on
    • It should be called lab01_yourgithubid
    • It should be private, not public.
    • The owner should be the UCSB-CS56-F16 organization as the owner, not your own github id.
    • Add a .gitignore for Java and a file
    • detailed instructions here
  5. Configure your CSIL account for git
  6. At the shell prompt on any of the csil machines, type the following command:
    ssh-keygen -f ~/.ssh/known_hosts -R
    • You need to do this because CSIL had new hardware installed over the summer, which caused the host key to change.
    • If you get a “no such file or directory” error, then you can skip this step
  7. Review a few basic facts about git, and
    • detailed information here
  8. Clone your lab01_yourgithubid repo into your CSIL account.
    • If you know how to do that, great.
    • If not, there are detailed instructions here
  9. Read through the Rational Tutorial.
    • For any of the repos, you can fork the repo into your own account. Here’s how:
    • Go to the repo page, e.g.
    • Click the “fork” button at the top right of the page
    • If asked where to fork it, choose your own account
    • Congratulations: you now have a forked copy of the cs56-rational-ex01
    • What do you do with it? Read on…
  10. Clone the cs56-rational-ex01 repo that you forked to your cs56 account (or your personal computer).
  11. Work through the eight examples shown so that you learn some of the basis material about how to work with Java:
    • java, javac, ant
    • build.xml files
    • JUnit testing
  12. You are now ready to work on your own lab.
    • Copy the files from the repo into the top level directory of your own lab01 repo.
    • This means all of the files, including the directories. You may need cp -r for the directories. If you need a refresher on unix commands, ask a mentor, TA, or instructor for help.
    • Commit an initial version of those files.
    • For that, you’ll need the basic git workflow, explained here
    • Once you have an initial version of the files, you are ready to start work.
    • Note that to commit the lib subdirectory, you may need the -f flag, as in git add -f lib/*.jar
  13. Follow the detailed instructions below to complete the assignment.

  14. When you are finished, be sure you have done a “git push origin master” to push your changes to github. Then, you can downloaded a .zip version of your assignment from github, rename it to, and submit via submit.cs at this link:

  15. Then, follow the additional instructions below to create javadoc for your project, publish it to a public repo (per the instructions) and post the URLs of your solutions to Gauchospace.

Detailed Instructions

method explanation
public static int lcm(int a, int b) returns least common multiple of a and b. See wikipedia discussion
public Rational plus(Rational r) returns sum of this number plus r
public static Rational sum(Rational a, Rational b) returns a+b
public Rational minus(Rational r) returns this number minus r
public static Rational difference(Rational a, Rational b) returns a-b
public Rational reciprocalOf() returns reciprocal (swap numerator and denominator). If numerator if zero, throws an instance of java.lang.ArithmeticException. To review exceptions, see cs56-rational-ex07
public Rational dividedBy(Rational r) returns this number divided by r
public static Rational quotient(Rational a, Rational b) returns a divided by b

Some hints to make things easier:

So, don’t repeat yourself:

Signify that you are finished by committing code to a github repo that contains a modified version of ex08, with all of the following:

Note that you will not be able to publish your javadoc online with the github pages technique (i.e. pushing to a gh-pages branch), because this only works with public repos, not with private ones. So, we’ve added some instructions below for publishing the javadoc to a separate public repo with the name lab01_javadoc_yourgithubid.

Publishing your javadoc online

  1. Create a public_repo with the name lab01_javadoc_yourgithubid under the organization with a (it is not necessary to include a .gitignore).
  2. cd into your ~/cs56 directory (or into whatever directory you cloned your lab01_yourgithubid repo). You want to clone your lab01_javadoc_yourgithubid repo into the same directory so that they are siblings, side-by-side in the same directory.
  3. We will now add some lines into your build.xml that copy the generated javadoc from your private repo to the public repo, and we’ll set the default branch of the public repo to be gh-pages. That process is explained in detail here: Javadoc: publishing to github pages from private repo
  4. Once you’ve followed the instructions in the link at step 3, your javadoc should be available online at a URL similar to the following one (but with your githubid instead of yourgithubid).

If you run into difficulties, ask your mentor/TA/instructor if in class, or ask on Piazza if outside of class.

When you are finished

When you are finished, you’ll have:

Visit the lab01 assignment on Gauchospace to paste these URLs into the “online text” submission area for lab01.