CMPS 134 – Fall 2014, HW #0 (Due: Tuesday September 2, 2014)
Homework #0 – Getting Started (Due: Tuesday September2, 2014)
This assignment consists of activities that are not indicative of the kind of work that you will be doing in “real” assignments throughout the semester, but rather are merely preparatory. Upon completion (more or less) of these activities you are to submit a message to me in accord with the instructions that appear in Part VI, near the end of this document. Your grade will be either 1 or 0, according to whether or not you submit an appropriate message.
If you have difficulties or are unable to complete these activities, I am available to assist you. Before seeking my help, however, you should give it your own best effort first and, if you get stuck, seek out classmates, friends, or the Technology Support Desk (941-HELP), in that order.
Part I – Register yourself on the “Course Web Page”
If you have not yet done so, visit the “course web page” at select(under the heading “Student Functions”) the hyperlink labeled “Register”, enter your Royal number (upper case R followed by eight digits), click on “Submit Form”, enter the requested data (you will have to invent a password), and then click on “Submit Form” again. After it responds that you have become authorized, verify it by navigating back to the course web page (e.g., by using the browser’s BACK button) and selecting “View Class Roster”. Your name should appear on the list when you click on the “Select” drop-down menu. Please take care to remember your password!
It is necessary that you complete this registration process because, otherwise, you will not be able to submit your assigned work forthis (or any subsequent) assignment. Themanner in which you will be submitting such work is described in Part VI. It involves clicking links on the course web page. You will use the same links in order to access my feedback to the work that you submit.
Part II – Describe your background
For this part of the assignment you are to compose a brief description ofyour experience using computing devices. I assume that you possess basic computer literacy. (If not, you may wish to take the C/IL 102 course before taking this one.) In particular, if you have ever done any computer programming, indicate how much and in which programming language(s).
CMPS 134 is an introductory course, so don’t be concerned if you do not know exactly what is meant by “programming”. Typically, more than 75% of students who enroll in it have never programmed before and thus are not familiar with any programming language. If this is the case with you, take comfort in the fact you likely will be in the majority.
Use Wordpad, Microsoft Word,or some similar toolto prepare this description and save it in a file. It should be a paragraph or two in length and be well written (i.e., using proper grammar and coherent sentences), such as would be expected of a capable college student.
Although this file could be attached to an email message and sent to me, I do not want you to do that! Instead, you are to send the file to me via the “Submit/Review” link provided on the course web pageadjacent to the link that brought you to this document. This is detailed in Part VI, near the end of this document.
Part III – Installing Javaand jGRASP on your own Personal Computer
As a necessary prerequisite to developing computer programs for this course, you will need to have access to a “programming environment” that aids the user in creating, modifying, and executing programs written in the Java programming language.
If you have a personal computer and intend to use it for work in this course, you should install Java, as well as an IDE (i.e., Integrated Development Environment). Several suitable IDEs exist, but the one that I recommend for use in this course isjGRASP. (Installation programs for both Java and jGrasp can be downloaded from the Internet for free. Detailed instructions appear below.)
If you have little or even no experience installing software, this assignment will benefit you in that it will require you to deal with some issues that you may not have encountered before. Generally,one installs software by“running”an installation program and then following the instructions and answering the prompts that are presented to you. (If you are given a choice for some option, it’s usually safe to pick the recommended or “default” option.)
Although some of the steps are detailed, there are important concepts behind these details that are worth discovering, even if the details remain a nuisance. The details often change, but the concepts persist, and this is a vitally important point to learn about computers and computing.
Do not attempt to install Java (or jGrasp, or any other software for that matter) on any public computer anywhere on campus. These software tools are already available on the machines in LSC 182 as well as some other labs on campus. Attempting to install such software in a public lab is likely not to work and may cause problems that employees from the University’s IT department will have to fix later.
As a duly registered student in a CMPS course, you are authorized to use the computers in LSC 182 (conveniently located across the hall from the offices of several Computing Sciences faculty), which is a lab where computing students gather to work on course projects. Your login ID there corresponds to your University ID (e.g., “smithj2”) and your password is your Royal Number (with an upper case ‘R’). Card swipe access should be operational by early in the semester.
Part IIIa – Installing Java
Java comes “pre-installed” on the Mac “platform”, so Mac users can skip this part and go directly to Part IIIb. Most of the rest of us usethe Microsoft Windows platform, so what follows is geared towards that group. If you happen to use some other platform, you should look for versions of the relevant tools (Java JDK and jGrasp) available for it. (You may very well find them at the same web sites where versions for Windows exist, so keep reading.)
In order to be able to develop and execute Java programs on your computer, you will need to install the “Java Development Kit”, or JDK. (It includes both the Java compiler, which translates Java “source” code into Java “bytecode”, and the Java Run-time Environment (JRE), which executes Java bytecode.)
Go to the course web pageand click on the link labeled Java SE 8 JDK Download (which you’ll find under the heading Java-related links). On the (Oracle Corporation) web page that appears, click on the“Download” button directly above the label Java Platform (JDK) 8u20. The page that appears next has a list of names of downloadable files within a table with the heading Java SE Development Kit 8u20. If your computer has a 32-bit processor architecture, click on the file name jdk-8u20-windows-i586.exe (2nd from the bottom).If it has a 64-bit architecture, click onjdk-8u20-windows-x64.exe (bottom-most).
Note: To determine your computer’s architecture (32-bit vs. 64-bit), you can “ask” it. If your machine is running Windows 7, do this: click the Start button, then right-click Computer, and then click Properties. The information presented should provide the answer. If your machine is running Windows 8, do this: click the icon at the bottom left of the desktop (bringing you to the “start screen”), then click the down arrow to bring up the “apps screen”, then within the “Windows Systems” group (way on the right) click on “Control Panel”, then click “Systems and Security”, and finally click “System”. End of note.
Once you’ve clicked on the correct file name and downloaded the file onto your machine’s hard disk drive, double click on the file’s icon in order to begin the installation. (Be sure to take note of where the file has been stored (i.e., which folder/subdirectory) so that you can find it.)
During the installation, you’ll need to accept the license agreement and make some choices as to settings. For the latter, I encourage you to choose the default settings. The installation may take several minutes.
Eventually you should receive notice that the process is complete, at which time you should click Finish. Your browser may open and present you with a page on which to register Java, but there is no need to do the registration.
During the installation process, take particular notice of the step that shows precisely where (i.e., in which subdirectory/folder) in your computer’s file system Java is being installed. Most likely it will be in
C:\Program Files\Java\jdk??????
where the ?’s will refer to the exact version number of JDK you are installing. When installation has finished, this subdirectory will have a subdirectory within it named “bin” that contains (executable) files named javac.exe and java.exe, which are the Java compiler and the JRE, respectively. (By convention, names of executable files end with the .exe extension.) If you can find these files in this location, you can be reasonably sure that you have completed this step satisfactorily.
Part IIIb – Installing jGRASP
Click on the link labeled jGrasp IDE on the course web page (under “Java-related links”). Near the upper right corner of the page that appears will be a link labeled Download jGRASP. Click on it, and on the resulting page find the button that says jGRASP.exe (or jGRASP.pkg for a Mac). (To be safe, you might prefer to download the version from July 2014 (2.0.0_15) rather than the “alpha” or “beta” versions from August 2014.) Click on that in order to download the installation program for jGrasp. Then run that program. Again you may need to accept the license agreement and you are encouraged to accept the default settings as you proceed. jGRASP is provided by Auburn University and it is frequently updated with new releases. As was the case with the Java JDK, any of the recent versions will be fine for our use this semester.
Part IV – Testing Java and jGRASP
Go back to the course web page and download the HelloWorld program. (You’ll find a link to it under the heading “Programming Samples”.) Before doing so, you may want to create a folder (named cmps134, perhaps) for storing the Java programs that you will be working on in this course. Don’t make the common mistake of placing all your files “on the desktop”, as soon it will become very cluttered and disorganized.
Now start jGRASP by clicking the icon on the desktop or finding it on the Start Menu. Your screen should now look something like the following, indicating that jGRASP is running.
As you can see, the interface is very similar to most windows based programs. After navigating to the subdirectory into which you downloaded the HelloWorld program, click on the “File” menu, select “Open”, and choose the file HelloWorld.java. The screen should now look something like the following.
The window just opened presents to you a small (but complete)Java program. This program contains instructions to have the computer print out the message “Hello, World.”. Before the program can be executed, we need to “compile” it, which means to translate it into a binary form (namely, Jave bytecode) that the JRE can “interpret”. To compile, select the button that looks like a green plus sign .
In response, a message similar to the following should appear in jGrasp’s console (bottom) window.
If you do not receive such a message, it may mean that the Java compiler (one component of the JDK) has not been correctly installed. The Java compiler is itself a program that performs the task of translating Java “source code” (e.g., the contents of the file HelloWorld.java) into instructions expressed in a binary form (Java bytecode) that the JRE is capable of executing. A successful compilation results in the creation of a Java “class” file (containing Java Bytecode); in this case, its name should be HelloWorld.class and it should reside in the same folder/subdirectory as HelloWorld.java.
Assuming that your compilation was successful, you can start the execution of the HelloWorldprogram by selecting the button that looks like a running stick-figure person . Selecting this button should result in a screen that looks like the following. Take special note of the console window (at the bottom) which now should show the result of (i.e., the output produced by) running the program.
If you obtained this result (namely, the string “Hello World” is displayed), it is clear that both jGRASP and Java have been installed and you are now ready to begin doing the “real” assignments of this course.
As your first programming task, modify the given HelloWorld.java program so that, in addition to outputting the message “Hello, World.”,it also outputs “Goodbye, Universe.”. To achieve this effect, you merely need to insert an additional statement into the program, immediately after
System.out.println("Hello, World.");
It is left for you to compose that statement.
Part V – Changing the Path Variable (optional)
After completing the instructions in this section, you will be able to invoke the Java compiler and the JRE from a “Command Prompt” window much more easily than you can now. Having this capability is simply a convenience, not a necessity. Moreover, if you make a mistake in carrying out this task, you may “mess up” your computer in such a way that restoring its functionality is a major nuisance. Hence, completing the instructions in this section is optional and is recommended only for students who are confident in their skill in working with computers. Computing majors are encouraged to make the attempt because they have a particular interest in gaining such skills and confidence.
Note that this part is relevant only to those using Microsoft Windows, and the particular instructions and screenshots apply to Windows 7. Windows 8 users will have to translate the instructions to analogous ones that work on that platform. Others should skip to Part VI.
Part Va – Changing the Path Variable
To change the Path variable, first you need to determine exactly where in your file system Java has been installed. Typically it will be in a folder named as illustrated in the following screen shot;in this case, C:\Program Files\Java\jdk.7.0_02\bin. Specifically we need to locate the files named javac.exe and java.exe, which are both in the folder.
Now open the “Control Panel” on the Start Menu.
Then select “System and Security”.
Here select “System”.
Then select “Advanced System Settings”.
In the System Properties window select “Environment Variables”.
In the System Variables area, locate the variable named “Path”.
After clicking the “Edit” button, advance to the end of the text in the Edit System Variable box. At this point enter a semi-colon followed by the full path name to the subdirectory in which Java was installed (i.e., the one containing the Java filesjava.exe and javac.exe). In the screen shot below “;C:\Program Files\Java\jdk1.7.0_02\bin” has been appended to the end of the Variable value.
After doing this, click “OK” all the way back to the Start Menu.
Part Vb – Testing the change to the Path Variable
Go to the course home pageand, under the Programming Samples heading, click on the link labeled MeanProgram . Download this program into the same folder as you did the HelloWorld program.
- From the “Start Menu” open a “Command Prompt” window. You’ll probably find it under “All Programs” and then “Accessories”.
- Change the directory (a.k.a. folder) to the one into which you downloaded MeanProgram.java. In my example here, I’ve named the directory C134, and so the command I typed was:
cd c:\C134
At the prompt, type in the command
javac MeanProgram.java
This command invokes the Java compiler. Assuming that thePath variable was changed correctly (and that a file named MeanProgram.java resides in the current directory), the result should be the creation of a file named MeanProgram.class, also in the current directory. You can verifythis by entering the command “dir”, which lists the names of files in the current directory.
If you receive an error message to the effect that “’javac’ is not recognized as a command”, this probably indicates that the Path variable was not properly changed. It does not necessarily mean that Java has not been installed. You should attempt to resolve this by repeatingPart Va.
- If step 2 was successful, then type in the command
java MeanProgram
This will cause the specified program to begin running. The program will repeatedly prompt you to enter an integer value. When you enter the value zero, the program will display the (arithmetic) mean (i.e., what is often referred to as the “average”) of the values you previously entered. If the program executes as outlined here then you clearly have changed the path variable correctly.
If you receive error messages then this probably indicates that the path variable has not been changed correctly. If however, jGRASP was installed correctly you should still be able to open, compile and run the MeanProgram.java file as illustrated earlier for the HelloWorld.java program. If this works then all is well ---maybe not perfect--- but well.