The goal of this lab is to check to make sure you can log on to the Linux Lab computers, and get some familiarity with the Linux system in this lab, as well as learning how to edit, compile, and run a Java program. Finally, we demonstrate the process of turning in your code on MyCourses.
To start, log on to the Linux Lab computer with your PODs userid and password. If you have problems getting logged on, see the help desk linux lab page (That's https://www.binghamton.edu/its/facilities/linux-lab.html if you are not already logged on.)
Next, open a terminal window. In the lower left corner of the Graphical User Interface (GUI), there is a Menu button, similar to the Windows start button. Click on that button to bring up the list of programs, and choose Accessories. This will add sub-menu to your display the list all the accessory programs installed on this computer. Scroll down in the Accessories list and click on the icon labeled Terminal. (Note... avoid the icon labeled "Root Terminal" for now. That one opens a terminal window too, but has some minor differences that may be confusing at this point.) When you click on the terminal icon, a terminal window will open up on your desktop.
It's also easiest if you have not done so already, to open a web browser, and navigate to this set of lab instructions on the Linux Lab machine.
The remainder of the instructions assume you will do all the work for this lab on a Linux Lab computer. If you have already installed Java on your laptop, and want to use your laptop for this lab, you may do so... but it's up to you to translate the instructions designed for a Linux Lab machine into similar commands and actions that work on your laptop. If you do so, don't forget to log off of the Linux Lab computer.
Your terminal window will start with you in your "home" directory. Each Binghamton University student gets a home directory associated with their PODs userid that can be accessed from any of the University Linux machines. (There is also a web interface that allows you to upload and download from your laptop to this space.) We are going to make a sub-directory of your home directory for the CS-140 class. It's best not to use blanks in directory names in Linux, so type:
> mkdir cs140 > cd cs140
The mkdir command creates a new directory, and the cd command does a "change directory" to move to that new directory.Next, we will make a sub-directory of the cs140 directory for today's lab and move to it.
> mkdir lab01 > cd lab01
Next, we will make a file call Quote.java, which contains the java that describes a stock quote class. For this lab, you don't need to actually write the code. The contents of the Quote.java file is actually provided for you on the printed sheet. (If you are in the first lab section, please hand this printed sheet back in when you are done so we don't have to waste so much paper.
There are several editors available on the Linux Lab systems, including vi, emacs, etc. However, the easiest and most intuitive to use is called "gedit". To create Quote.java and open up the editor on that file, type the command:
> gedit Quote.java &
Once you have typed in Quote.java and saved it, compile your java program in the terminal window by typing:
> javac -d . Quote.java
If you typed everything correctly, your program should compile with no errors. If not, you will probably get compiler error messages, and you will have to edit Quote.java and fix your mistakes.
Once you compile clean, download the following files and save them in your cs140/lab01 directory:
When you are done, check to make sure you have all these files in the lab01 directory by typing
If you don't have all the right files in the right places, get help.
Next, we will compile all the code you have downloaded:
> javac -d . *.java
If you are curious, feel free to edit the new java files to see how they work. It's a little early to understand everything, but you can get the basic idea.
We finally have all the objects defined, but we need one more java program... this one to create and manipulate the objects defined in the rest of the java code. For this last piece of code, look on the back of the printed sheet, and find the contents of "Tester.java". Create a file called Tester.java, and copy the code into that file. Now, compile Tester.java as well.
> javac -d . Tester.java
Finally, run your java program. This is done by:
> java -cp . lab01.TesterLook at the output produced by the result. If there are any exceptions, then you did something wrong. For instance, is the "quotes.txt" file in the right place?
One last thing we can do (if you have time left) is to automatically create documentation for this code. If you are running out of time, skip this step... just do a cd .. to get back to your cs140 directory, and skip to the next heading.
If you do have time, type the following commands:
> cd .. > javadoc -d lab01/doc lab01After this is done, do an:
> ls lab01/doc
To see all the html files that javadoc has created for you automatically. You can open these with an editor, but its a lot more interesting to open them with a web browser to see how they look on the web.
Remember from the lecture, and if you followed the instructions, you will now have two lab01 directories. The top level lab01 directory will contain your Java source code, and a lab01 sub-directory. The lower level lab01 directory will contain the bytecode .class files. In order to create a zip file, you need to be in the parent directory of the top level directory. Double check by using the command ls lab01. If the result shows your .java files, you're OK. If it shows .class files, you need to cd .. to move up one directory. If it says "lab01 directory not found", you are in some bizarre directory and need to get back to where you started.
Once your current directory is the parent of the top lab01 directory, create a zip file that contains everything in the lab01 directory by typing the command
> zip -r lab01 lab01
This command will create a lab01.zip file, and print messages about all the files zipped together to create the lab01.zip file. The -r flag in the zip command causes zip to recursively include files in sub-directories as well as the files in the top level lab01 directory.
Now, go to MyCourses using your web browser, and open the CS-140-B1-Fall17 course labeled Fall 2017 - Programming with Objects (LEC). (Notice that you also have a CS-140-B55 or B56 course. We will not be using these at all this semester. I usually remove these from view in the My Courses tab.) Click on the "Content" hyperlink in the left column. There is a "Lab Submissions" folder on the content page. Click on the "Lab assignments" hyperlink, and you will see "Lab 01 Submission". Click on that hyperlink, and use the Browse My Computer button to upload "lab01.zip" from your cs140 directory in that area, and submit. Then you are done. As long as you did the requested work, and submit a correct lab01.zip file before the due date of August 29 at 11:59 PM, you will get full credit for the lab.
In this course, you may submit assignments and lab submissions as many times as you wish. Only the last submission will be graded.
Once the TA's have graded this lab, you will see can check your score and any feedback the TA's provide by going to MyCourses CS-140 Grade Center.