|
|||||
Home |
Resources | Homeworks |
Exams |
PurposeThis lab has several parts that prepare you for future labs and homeworks. The goals of this lab are:
We have created two Java program files that you are to manipulate and then submit as part of this lab. The files are MyName.java and CompileError.java. Their use is discussed later. If you have any questions, please raise your hand to ask a teaching assistant to help you - this is the purpose of having the lab sections. Most students will have a basic knowledge of using Windows. If not, then no problem -- just ask a TA for help. In an effort to keep this lab text (relatively) short, the details about copying files and such have been left out. The TAs can help with this. Working in PairsBecause of the lab scheduling issues for the first week, you are allowed to work in pairs for this assignment but only if there are no free computers. Thus, the honor policy of not looking at somebody else's code does not apply for this lab. However, each person must submit the files under his/her own username. Home DirectoryWhen you log into the machine, a home directory login will appear. Log into your home directory using your UVa ID and the appropriate password. Your username should be of the format \\ESERVICES\mst3k, where mst3k is your userid. The Server Name should automatically say \\HOME1\mst3k. By default your home directory will be mounted as the J: drive. If your home directory password does not work, or you have forgotten it, see here. You can install the home directory service on your home machine as well - see http://www.itc.virginia.edu/desktop/homedir/. All your submitted files must be copied to your home directory before the due date of the assignment. If there is a problem with the submission, then only the copy in the home directory will be considered to resolve the issue, and only if it was copied there before the assignment was due. If your home directory is not working for this lab, you can save the files on the local computer, and then e-mail them to yourself when they are completed -- this will serve as a backup for this lab. Assignment submissionWe first want you to become familiar with the Submissions page of the CS 101 website. We suggest that you do so in a different browser window. You can do so by right-clicking on the preceding link and select "Open in New Window" or "Open Link in New Tab". The five links on the left side of this page allow you to manage and review your assignment submissions for this course. Note that all students who are registered for the course (either a lecture or a lab section) should have an account created for them -- both to log into the lab machines, and to use the grading system. If you are missing either, please see a TA.
Introduction to Java and JCreatorPut a copy of MyName.java in your Home Directory folder by right clicking on the link and select "Save Link As" (or "Save Target As"). Note that if you just click on the file, although it will load up into JCreator, it may not compile correctly. Next load the file into JCreator. You can do so by either double clicking on the copy of MyName.java in your Home Directory folder, or by starting up JCreator and then select the Open entry of the File menu (i.e., select File->Open) and find the MyName.java file. While this lab does not discuss the various parts of the MyName.java program mean, please examine the two lines that start with System.out.println. Each of them prints out a line of text. Press the compile button at the top of the window, which is shown highlighted in the image on the right. This will start the compilation of the Java program. All Java programs must be compiled before they are run. Essentially, computers do not understand Java code. The compiler will translate the Java code that you write into a form that the computer can understand. That translated code is then run when you execute the program (below).
The bottom of the screen will show the status of the compilation, as seen in the next image.
If there were any errors, they would be reported there. "Process completed" means it compiled without any errors. Note that sometimes JCreator will hang while trying to compile a program. If so, the lightning bolt button (shown below) will fix the situation. Note that this button only lights up when JCreator is compiling a program, and it will be grayed out otherwise.
Next, you can execute the program. To do this, press the execute button, which is shown highlighted below. This will pop up a black window, as shown below. This window shows the output produced by the execution of the program. For this program, it shows the two lines printed via the two System.out.println lines in the program code. Now edit the file in JCreator, and change the name and email address in the header (the first 3 lines, which are green-colored in JCreator, are the header). These comments are ignored by Java, and can contain anything that you want. Next, change the second System.out.println line to your own name. Then save your file (File->Save), compile it, and run it. If you are working in pairs, put both of your names in the header, and in the System.out.println statement. Note that all of the ITC labs in the University have Java and JCreator installed, and you are welcome to do your homeworks on those computers (especially if you don't have your own computer). However, they have a slightly older version of JCreator -- although it works the same, the buttons will look a little different. Submitting the fileWe want you to submit the file, so click on the Submit an assignment link. Again, it will probably be easier to open up the page in a new window (right-click on the link and select "Open in New Window"). The submission form will often have a few survey questions to fill out. These questions are there so that we know how we are doing, and will ask things such as how useful you felt the assignment was, how long it took, etc. For most labs, there will only be a few questions, including "How well did you understand the concepts gone over in this assignment". Select the appropriate answer. This lab also asks you to enter your sex as well. There is also a comments box, where you can state any remarks that you have about the assignment. We are interested in this feedback, and will read each of the comments and try to use them to improve the next course offering. You will notice that some questions are required (such as the "how well did you understand this"), while others are optional (the "general comments" question), and are indicated as such. Note that only one set of answers is recorded per person per assignment. Thus, you don't need to give a different set with each file you submit. If you do give a new set of answers, your old set will be overwritten. The process to submit a file is as follows. Enter your e-mail ID and password, select the assignment (Lab 1), and click on "Browse..." to select the file to submit. This will pop up a window that will allow you to find the file you want to submit (MyName.java). Note that you want to submit the file with the .java extension, rather than the file with the .class extension. Fill out the survey, then click on the "Submit" button at the bottom. If there is a problem with the submission, it will state so. Otherwise, it will tell you that your submission was successful. If you are working in pairs, each person must separately submit the file under his/her username. Checking the submission and its compilation statusYou can check which files have been submitted. To do so, make sure the User ID and Password fields are filled out, and select the correct assignment (Lab 1) from the assignment selection box. Then click on "List". This will list the file(s) submitted for this assignment. Note that the assignment is currently incomplete, shown by the blinking red "file not found", as only one of the two required files has been submitted so far (the second will be submitted below). The listing will also show the code for the file(s) that have been submitted. If you do not submit all the files, you will not receive full credit for the assignment. We'll submit the second file for this lab below. Next, make sure the User ID and Password fields are filled out, and select the correct assignment (Lab 1) from the Assignment selection box. Then click on "Compile". This will compile the file(s) submitted. Doing this compilation is important, as it will check to see if there are any errors. If your submission does not compile, you will get lots of points off for the assignment. Thus, it is in your interest to make sure that all submitted files successfully compile. Because only one of the two files has been submitted, this compile check will also state that one file is missing. The second file
Java and JCreator InstallationStudents often find it convenient to install Java and JCreator on your their machines -- they do not have to go to UVa public lab. The installation is not required as all UVa public machines have both tools installed. If you choose to install the software, please realize that we offer advice, but we are limited in how much support we can provide for this activity. If you have a laptop, and run into installation difficulties, you can bring your laptop to office hours and one of the TAs or instructors can help you install the software. If you have a Macintosh computer, you can find detailed installation instructions here. For Windows, we provide brief instructions below. Both of the programs listed here are free to download and install.
For the tools to install correctly you need to install Java BEFORE you install JCreator. You can install the home directory service on your home machine as well - see http://www.itc.virginia.edu/desktop/homedir/ Finishing UpThis completes the lab. Be sure to log out! No need to restart the computer, though. |