Setting_Up_Your_Computer

Document Sample
Setting_Up_Your_Computer Powered By Docstoc
					                Appendix A
        Setting Up Your Computer
Programs built with the Java Language run on Windows, MacIntosh and variations of Unix
including Linux. The ACM Java Library works on these computers also.

This chapter tells you how to set up a Windows or MacIntosh computer to use Java, the ACM
Java Library and several different programming environments. If someone will pass along
instructions on how to set up a Unix/Linux programming environment I’ll be happy to add that
to this chapter.

The instruction lists file locations and names current as of Sept. 1, 2009.


A.1 Installing Java
Java is a free programming and runtime environment from Sun Microsystems. As a CS student,
you need the Java Development Kit (JDK) to compile and run your Java programs.

Install Java before installing your programming editor! Doing so generally allows the editor to
find Java on your hard drive and connect with it automatically, which makes your life much
easier.

Windows
Currently you can find what you need at http://java.sun.com/javase/downloads/index.jsp Look
for the JDK with the highest version number and highest update number, currently JDK 6
Update 17.

   1) Click the Download button for the highest version and update number.
   2) Select your platform (probably Windows)
   3) Click the Continue button
   4) Click the "Skip this Step" option
   5) Click the highlighted file name (currently jdk-6u17-windows-i586.exe)
   6) Save the file to your desktop. The download begins and will take quite a while. Have a
      cup of coffee.
   7) When the file is installed on your desktop, run it.
   8) The JDK should now be installed on your computer.




©Daniel L. Schuster, 2009, all rights reserved                                          Page #1
MacIntosh
Oh you lucky Appleites. The JDK comes installed on every recent Mac running the OS X
operating system. For updates go to developer.apple.com/java/download


A.2 Downloading the ACM Java Library
The ACM Java Library comes in one file: acm.jar. Your instructor may make the acm.jar file
available on your campus network. If not you can download it for free from the web. You’ll use
the same acm.jar file for Windows, Mac and Linux.

   1) Browse to www-cs-faculty.stanford.edu/~eroberts/jtf/
   2) Click on acm.jar and save the file in some convenient location


A.3 Folder & File Arrangement
In your Java work you’ll write quite a few programs. All of these programs will need to connect
with the ACM Java Library and some of those programs will be made of multiple files.

Keeping all these files straight can be difficult and you’ve got to tell your editor how to find the
files it needs, so some organization is important. Here’s what I recommend.

Organization Method 1—put all of the programs in their own subfolders and put the acm.jar file
also in each subfolder.
                                        myJavaFolder



             BounceBall                       FlyUFO                          Asteroids

       acm.jar                         acm.jar                         acm.jar
       BounceBall.java                 UFO.java                        UFO.java
                                       FlyUFO.java                     Bullet.java
                                                                       Blackhole.java
                                                                       Asteroid.java



Organization Method 2— put all of the programs in their own subfolders and put the acm.jar
file in your myJavaFolder.




©Daniel L. Schuster, 2009, all rights reserved                                               Page #2
                                        myJavaFolder

                                           acm.jar

            BounceBall                       FlyUFO                          Asteroids

       BounceBall.java                UFO.java                         UFO.java
                                      FlyUFO.java                      Bullet.java
                                                                       Blackhole.java
                                                                       Asteroid.java




In either case you will normally hand in the entire folder—BounceBall or FlyUFO for example.

If your instructor has other ideas follow his/her instructions carefully or it may be impossible for
the grader to compile or run your program.


A.4 Setting Up Dr. Java
Dr. Java is the preferred development environment for the Free Java Book. It is an easy to use
but powerful editor and development environment. It is available via download and is free.
Free as in $0.00! It is available for Windows and Mac.

1) Make sure that Java is installed before you install Dr. Java. That way, Dr. Java will find Java
   automatically
2) Download Dr. Java from www.drjava.org. You’re downloading the actual program, not an
   installer. Download the Windows App or Mac OS app.
3) Test your Dr. Java and Java setup
     a. browse to your myJavaFolder and open it.
     b. create the HelloWorld folder within it
     c. if required by your organization scheme, copy the acm.jar file into your HelloWorld
         folder
     d. start Dr. Java and type in the HelloWorldConsole program from Chapter 1
//HelloWorldConsole.java
import acm.program.*;

public class HelloWorldConsole extends ConsoleProgram
{
       public void run( )
       {
              println("Hello World");

©Daniel L. Schuster, 2009, all rights reserved                                              Page #3
       }
                                                                     note extra required
       public static void main(String[ ] args)                       code for the Dr. Java
       {                                                             environment
              new HelloWorldConsole( ).start(args);
       }
}
          a. be very careful as any typos will probably cause the program to fail to work
              properly
          b. save the file as HelloWorldConsole.java (use the same capitalization exactly) in
              the HelloWorld folder
     e. tell Dr. Java where to find the ACM Library
          a. click Edit-Preferences
          b. click Resource Locations
          c. click Add and browse to the myJavaFolder.
                    i. Method 1 organization: browse to the HelloWorld folder then click on
                       acm.jar
                   ii. Method 2 organization: click on the acm.jar file in the myJavaFolder
          d. click Select then OK
     f. compile the program
          a. click the Compile button (upper right part of the window)
          b. if you get errors, go back and look for things that are not typed in correctly
     g. run the program (when all of your compile error are fixed)
          a. click the Run button
          b. the phrase “Hello World” should appear in the console window.


A.5 Setting Up TextPad
TextPad is a very simple but useful Windows editor and development environment. It is
available via download, is free for evaluation but costs $16.50 British pounds (currently about
$27.50 U.S.) if you use it for an extended period.

    1) Make sure that the JDK is installed before you install TextPad. That way, Textpad will
       find Java automatically
    2) Download the Textpad installer from www.textpad.com and save it on your desktop.
    3) Run the installation program
    4) Start TextPad
    5) Configure TextPad
           a. add the Tools for the Java SDK
                    i. click Configure-Preferences
                   ii. click Tools at the bottom of the list
                  iii. click Add (top right)-Java JDK commands
                  iv. click Apply
           b. set up the Tools

©Daniel L. Schuster, 2009, all rights reserved                                           Page #4
                   i. click +Tool, which expands the tools menu
                  ii. click Compile Java
                 iii. enter the following in the parameters box
                              -cp .;.\acm.jar $File
                 iv. click Apply
                  v. click Run Java Application
                 vi. enter the following in the parameters box
                          -cp .;.\acm.jar -ea $BaseName
                vii. click Apply
         c. set up the syntax highlighting
                   i. click Configure - Preferences - +Document Classes - +Java - Syntax
                  ii. click the ‘Enable Syntax Highlight’ checkbox if it isn’t already checked and
                      select java.syn as the syntax definition file
                 iii. click Apply
         d. click OK
   6) Test your TextPad & Java set up
         a. browse to your myJavaFolder and open it.
         b. create HelloWorld folder within it
         c. if required by your organization scheme, copy the acm.jar file into your
             HelloWorld folder
         d. start TextPad and type in the HelloWorldConsole program from Chapter 1
 //HelloWorldConsole.java
 import acm.program.*;

 public class HelloWorldConsole extends ConsoleProgram
 {
      public void run( )
      {
              println("Hello World");
      }
 }
                   i. be very careful as any typos will probably cause the program to fail to
                      work properly
                  ii. save the file as HelloWorldConsole.java (use the same capitalization
                      exactly) in the HelloWorld folder
          e. compile the program
                   i. choose Tools-External Tools-Compile Java (or use the Ctrl+1 shortcut key)
                  ii. if you get errors, go back and look for things that are not typed in
                      correctly
          f. run the program (when all of your compilation errors are fixed)
                   i. choose Tool-External Tools-Run Java Application (or use the Ctrl+2
                      shortcut key)
                  ii. a black window should open, followed by the white console window
                 iii. the phrase “Hello World” should appear in the console window.

©Daniel L. Schuster, 2009, all rights reserved                                            Page #5
A.6 Setting Up NetBeans
NetBeans, despite the goofy name, is a possibly the development environment for the multi-
language professional. It is also free. It is available for Windows, Mac and Unix/Linux variants.
I’ll get instructions here eventually.


A.7 Setting Up the Mac Trackpad for a Right Click
Macs come with a one button mouse, but can be configured to work as if there was a two
button mouse. Here’s how.

1)   click the Apple icon
2)   click System Preferences
3)   click Keyboard and Mouse
4)   click the Trackpad tabe
5)   click the checkbox for “For secondary clicks place two fingers on the trackpad then click the
     button.” The wording may be slightly different.

Alternatively I understand that a two button USB mouse will automatically work.

Many games and some of our programs may require a right click.


A.8 Backing Up Your Hard Drive
Ok, you know this already—you should be backing up your hard drive. I’d like to suggest some
easy ways to do it.
                     BACKUP - BECAUSE FAILURE IS NOT AN OPTION!

Arranging your hard drive
You’ve probably got school work, personal stuff, music, movies and pics on your computer. Put
all of your school work in one folder (let’s call it SchoolJunk), arranged in subfolders within that
one folder. Our discussion assume that the folder you have to backup is SchoolJunk.

Backup media
You can backup to several different storage devices.

Flash drive – if you’ve got a laptop spend another $15 on a 4 GB flash drive from a quality
manufacturer. When you make a change copy that file (or the whole SchoolJunk folder) to the
flash drive. If you use quality flash drives they are very reliable, but use two of them if you want
to be very careful. Flash drives with removable caps are a pain in the keister. Get something
with a cover that removes but stays attached so you don’t lose it. Now you’ve got a quick
backup while you’re on the go.


©Daniel L. Schuster, 2009, all rights reserved                                              Page #6
External hard drive – you can backup your SchoolJunk folder by copying the whole thing to your
external hard drive from your laptop or desktop. External hard drives are around $75 to $125
and usually connect via USB. They may or may not require a separate power cord. You can buy
drives designed to sit on your desktop or smaller and lighter drives that can go in your bag with
your laptop.

CDs and DVDs – not enough space these days, but you can certainly do a backup of just your
Java work. CDs are around 600MB, DVDs around 5 GB I think, suitable for small backups but
slow.

Online backup – seems like a great idea to me, reasonably priced and it ought to work very well,
but I have no experience or recommendations. You may be concerned about privacy, but these
services typically encrypt your files so they should be private.

Backup software
Backup software can be set to automatically perform backups when there is a change or at a
specific time of the day. Typically backup software only backs up files that have changed since
the last backup, so it runs often runs very quickly.

External hard drives often come with backup software included.

I have no software brands to recommend. I just copy my entire SchoolJunk folder when I want
to do a backup. Takes about 10 minutes for me and it's simple.

What’s my scheme
I have three computers.

My school desktop is backed up automatically every night on the campus network. Computer
services set this up for me and as far as I can tell it works great.

My personal desktop at home gets backed up weekly to an external 500GB hard drive I bought
for about $110 from Wally World. If I lose my desktop between backups it’s no big deal because
I don’t use it much anyway.

My personal laptop is backed up to a flash drive everytime I make a significant change to a file. I
copy this flash drive to the hard drive on my desktop weekly, and that is backed up to the
external.

Traveling is much harder on a laptop than use around the home. In that case I bring two flash
drives and back up everything to both of them.

Emergency backup


©Daniel L. Schuster, 2009, all rights reserved                                             Page #7
So what do you do if you’ve just got to back up and you don’t have anything to back up to.
Maybe your computer is acting weird or you hear a high pitched squeal (possibly indicative of a
failing bearing in your hard drive—don’t laugh, it’s happened to me twice) coming from your
computer. What do you do?

It’s easy if you’ve got internet access. Just mail it to yourself.

1) If you need to backup a folder, begin by compressing it. To do this in Windows, right click on
   the folder and choose Send To/Compressed (zipped) folder. Macintites, can’t help but it
   should work similarly.
2) Open up hotmail or whatever, send an email to yourself and include the file or compressed
   folder as an attachment. Hotmail accepts 10MB attachments, Gmail 25MB . Your mileage
   may vary, but if you’re backing up that fabulous game program you just wrote or the history
   paper that wil change the world, you’ll have plenty of room. Remember that all you need to
   back up is your .java files, so delete anything else if you need to cut megabytes.

And if you don’t have internet access? Uhhhhh, hope for the best?




©Daniel L. Schuster, 2009, all rights reserved                                           Page #8

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:11
posted:7/16/2012
language:English
pages:8