CIS 455/555: Internet and Web Systems Spring 2017

Assignment 0: Using the Virtual Machine Image Due January 25, 2017, at 10:00pm EST

1 Background We will be offering a standardized development system for CIS455/555 that is based on a virtual machine image. This image contains a small Linux installation, the Eclipse IDE, and all the tools you will need for the homework assignments. Having such a standardized system has several advantages: 1. You do not have to worry about incompatibilities between the software we will be using and other software that may be installed on your machine; 2. If something goes wrong, you have a 'safe' configuration to go back to - just reinstall the virtual machine image; 3. The virtual machine image will be the 'gold standard' for grading; thus, if your solution works in the VM image, you can be sure that it will also work on the graders' machines. You should be able to use the VM image with several different virtual machine monitors (VMMs), e.g.: • • •

Oracle's VirtualBox (http://www.virtualbox.org/). Available for free; works on Windows, Linux, and MacOS. This is the recommended platform. VMware Workstation Player (http://www.vmware.com/products/player/playerproevaluation.html). Free for students; works on Windows and Linux. VMware's Fusion (http://www.vmware.com/products/fusion). This has better performance that VirtualBox, but it is relatively expensive. Works on MacOS.

VMware Workstation Player should also be available in some of the Linux labs (M100A, M204/Ketterer, M207, Towne-M70). If you would like to use the VM with the lab machines but do not have enough free space in your account, please let us know - we can ask CETS to give you some extra space . Of course, you are free to use a different development system (e.g., a different operating system, your favorite editor or IDE, ...) instead of the VM; however, we will only grade solutions based on their performance in the virtual machine image, and we can only offer limited support if you decide to use your own setup.

2 Installing the VM image Your first task is to install the VM image for this assignment. If you are using VMware Workstation Player: 1. Download the VM image from http://www.cis.upenn.edu/~cis455/handouts/vm.zip 2. Unpack the .zip file; this should produce a folder called cis455

3. Start VMware Workstation Player 4. Click ‘File -> Open’. In the dialog box that appears, open the cis455 folder, select the CIS455.vmx machine image, and click 'Open'. 5. Click 'Play virtual machine'. If it asks whether the VM was moved or copied, say 'I moved it'. If you are using VirtualBox: 1. Download the VM image from http://www.cis.upenn.edu/~cis455/handouts/vm.zip 2. Unpack the .zip file; this should produce a folder called cis455 3. Start VirtualBox and click ‘New’. For name, enter ‘CIS455’. Set the type to ‘Linux’ and the Version to ‘Ubuntu (64 bit)’. Click Next and set memory to 2048 MB 4. Check “Use an existing virtual hard drive file”. Open the cis455 folder and select Virtual Disk.vmdk. Click Create. (If you get a "Failed to open disk image" error, we recommend that you try the slightly older version 4.3 of Virtual Box, which you can download from https://www.virtualbox.org/wiki/Download_Old_Builds_4_3. 5. Click Start. If you are using VMware Fusion: 1. 2. 3. 4.

Download the VM image from http://www.cis.upenn.edu/~cis455/handouts/vm.zip Unpack the .zip file; this should produce a folder called cis455 Rename this folder to CIS455.vmwarevm Double-click on the folder in Finder; the VM should open directly. If it asks whether the VM was moved or copied, say 'I moved it'.

Whether you are using Workstation Player, Fusion, or VirtualBox, the Linux in the VM image should boot now. Wait until the login dialog appears. Click on 'CIS455' to log in. The password is vm.

2.1 A few tips regarding the virtual machine •



Always (!) shut down the VM properly before closing your VMM (by clicking on the 'CIS455' the upper right corner and selecting 'Power Off'). If you do not do this, the VM image can become corrupted, just like your operating system can become corrupted if you switch off your computer before shutting it down properly. In particular, do not just 'power off' the virtual machine using the command in Player/VirtualBox/ Fusion, and do not just close the VMM altogether. Always hit the button that is highlighted in the screenshot on the right, and wait for the VM to power off on its own. If the screen size of your VM is tiny, try resizing it or putting it into full-screen mode. If this doesn't do anything, you may need to reinstall the Guest Additions for your particular VMM. For instance, if you are using VirtualBox, start the VM and then choose "Install Guest Additions CD Image" from the "Devices" menu. After a few seconds, you should see a dialog box in the VM that asks you whether you want to automatically run the software; click "Run". You will be prompted for the root password; enter "vm". The VM will open a terminal window, compile a





• • •

few things, and then ask you to press Return. Do so, and then reboot the VM as shown above (do not simply close VirtualBox!!). Once the VM has rebooted, you should be able to resize it. Note that the mouse pointer has to be over the VM window; otherwise your inputs will not be accepted. If at any point your mouse or keyboard are 'captured' by the VM (i.e., you can no longer move the mouse outside of the VM window or switch to other applications), press the 'Ctrl' and 'Alt' keys simultaneously (or ‘Right Ctrl’ in VirtualBox). This should also help you to get out of 'fullscreen mode'. The data you store inside the VM is persistent (i.e., will survive reboots), and we will be using a version control system; nevertheless, we strongly recommend that you make occasional backups, e.g., by copying your data to eniac.seas.upenn.edu using the scp command. The password for the cis455 user is vm. You shouldn't normally need to become root, but if this ever becomes necessary, you can use sudo with the same password. If you would like to use a text editor other than Eclipse, please use apt-get to install it. For instance, to install gedit, run sudo apt-get install gedit in a terminal window. If the virtual disk (the .vmdk file(s) in the cis455 folder) is getting too big, try deleting some files inside the VM and then 'compacting' it (under Virtual Machine Settings... / Hard Disk (SCSI) / Utilities / Compact). This should free up some space on the host machine.

If you want to set up a shared folder between your VM and your own machine to easily access files in your VM when you’re outside the VM, you can set up a shared folder as follows: If you are using VirtualBox: • If you haven't already, install the Guest Additions as described above (important!) • Open VirtualBox, select your OS on the left then click on Shared Folders on the right. • Click on the green cross on the top right to add a new Shared Folder • Fill out the form by selecting which folder you want to shared between your machines. Check auto mount and Save. • Start up your Ubuntu now and navigate to /media and you will see your shared folder as “sf_FolderName”. However, if you try and open it you’ll get a permissions error. • In order to access it from inside the vm, you need to open Terminal and paste in the following command: sudo usermod -a -G vboxsf cis455 (you'll need to reboot the VM after this!)

2.2 Configuring the VM Next, you need to configure the VM. To do this, open the Chrome browser in the VM (by clicking on "Activities" and then on the Chrome icon) and then enter the following URL: https://alliance.seas.upenn.edu/~cis455/cgi-bin/getconfig.php The web page will ask you to log in with your PennKey credentials. Once you have done this, Chrome will automatically download a file to your VM, and you will see a warning at the bottom of the Chrome window ("This type of file can harm your computer..."). Click on the "Keep" button next to the warning. Now close Chrome and open a terminal ("Activities" and then the little computer icon). Enter the following into the window that appears: cis455@vm:~$ chmod 755 Downloads/configure-vm.sh cis455@vm:~$ ./Downloads/configure-vm.sh

If all goes well, you should see a message that starts with "Your VM is now configured for ..." and that contains your name, SEAS login, and email address. If you do not see this message; please check Piazza for solutions.

3 The HelloWorld application [10 points] Your third task in this assignment is to write a simple Java program that writes your full name and your SEAS login name to System.out when it is invoked (for example, my own solution writes "*** Author: Andreas Haeberlen (ahae)"). The class that contains your main method should be called HelloWorld, and it should be a member of the package edu.upenn.cis455.hw0. This is not rocket science. We know. The goal is to familiarize yourself with the VM, and to try out the homework submission process, which is described below. In the following, we will assume that your VM can successfully connect to the network. If you are not sure about the network connection, click on "Activities" in the menu bar and then on the "Google Chrome" icon on the left; this should open the CIS455 web page. To get started, open a terminal window (click on "Activities" and then on the little terminal) and then enter the following two command: cd ~/workspace/ rm -rf .metadata git clone ssh://[email protected]/git/cis455/yourSEASlogin/ .

but replace the two occurrences of yourSEASlogin with your actual SEAS login name. Do not forget the dot at the end, and do not add or omit spaces! You should now see messages like this: Cloning into '.'... remote: Counting objects: 13, done. remote: Compressing objects: 100% (7/7), done. remote: Total 13 (delta 0), reused 0 (delta 0) Receiving objects: 100% (13/13), 30.46 MiB | 38.50 MiB/s, done. Checking connectivity... done.

Next, open Eclipse (click on "Activities" again, and then on the Eclipse icon). Click on "File" / "Import...", expand the "General" option in the dialog that opens, pick "Existing Projects into Workspace", and hit "Next >". Click on "Browse ..." next to "Select root directory", click on the "HW0" folder, and finally click "OK" and then "Finish". The project should now be imported into Eclipse. Next, find the HelloWorld.java file, and add the necessary code to write your full name and SEAS login. Please use the exact format above (Example: "*** Author: Andreas Haeberlen (ahae)"). Also, open the README file and complete all the fields. Finally, check all your changes back into the repository. To do this, go back to your terminal window (or open another, if you closed it), and enter the following commands: cd ~/workspace/ git commit HW0 -m "Solved HW0" git push

Your changes should now be checked in. For later assignments, we strongly recommend that you regularly check in your changes, at least once a day and/or whenevery you've implemented a major new feature. That way, when something suddenly stops working, you can use git's diff feature to find the changes you've made since the last checkin. Also, when you create additional files, please don't forget to add them to the repository.

4 Packaging and submitting your solution Once you are ready to submit, you should first check in all your changes. After that, you should prepare a package with your source code as follows. First, open another terminal window as described above. In that window, run the following commands (text you should type is underlined): cis455@vm:~$ cd ~/workspace/HW0 cis455@vm:~/workspace/HW0$ ant pack Buildfile: /home/cis455/workspace/HW0/build.xml pack: [zip] Building zip: /home/cis455/workspace/HW0/submit-hw0.zip BUILD SUCCESSFUL Total time: 0 seconds cis455@vm:~/workspace/HW0$ This will create a file called submit-hw0.zip, which should automatically include all the source code you have written (to verify, you can run unzip -l submit-hw0.zip). Next, open Chrome and go to the following page: https://alliance.seas.upenn.edu/~cis455/cgi-bin/submit.php You should see a list of homework assignments, along with the due date for each, as well as a submission form at the bottom of the page. Choose "HW0" from the "Choose an assignment" dropbox, then click on "Browse..."; in the dialog box that opens now, navigate to the /home/cis455/workspace/HW0 folder, and select the submit-hw0.zip file you just created. Finally, click on the "Submit" button. You should see a message saying that your solution has been receiveed. The submission system has an automatic checker that performs some basic checks on each new submission (e.g., whether it is a valid zip file, and whether it builds correctly). This checker only runs every couple of minutes, so the results won't be available immediately. At first, the status of your submission will show up as "Pending..." (in orange); once the checker has run, the status will either change to "OK" or "FAIL". Please do not keep hitting the "Reload" button while you wait - just check back five minutes after you submitted the file! If the checks fail, there will be a link to a page with some additional information; you should look at this information and fix any problems. You can resubmit at any time before the deadline.

5 Requesting extensions We strong recommend that you start working on each assignment as soon as it becomes available. That way, if you encounter an unexpected problem that you cannot resolve by yourself, you will have enough time to post a question on Piazza, or to come to office hours. However, we do realize that things do not always go as planned. Therefore, you automatically receive three 'jokers' at the beginning of the semester, which you can redeem for a one-day extension. To redeem a joker, please go to https://alliance.seas.upenn.edu/~cis455/cgi-bin/submit.php You will see a list of assignments, the corresponding deadlines, and the number of remaining jokers. To spend a joker to extend one of the deadlines, click on "Extend". You can spend all jokers on one assignment, or each joker on a different assignment; however, you cannot extend a deadline that has already passed (it is ok to spend one joker before the original deadline, another one the next day, etc.). Once you have spent your three jokers, you cannot get further extensions for any reason, and each late day will lower your score by 20%. Therefore, we recommend that you try to save your jokers for emergencies and/or the inevitable time crunch at the end of the semester. The best way to save your jokers is to start early.