SIMS 255: Lab 11

Wednesday, November 6, 2002

Disk-based Hashing

Installing Sleepycat for use with TextPad

Sleepycat Diagram
  1. Copy the file dbtool.zip to your desktop and unzip it.

  2. Open the folder 'dbtool' that is now on your desktop. Note that winzip made an inner folder with the same name, 'dbtool'. Copy that inner folder to your H drive, wherever you keep your Java projects. You can now delete the folder on your desktop, or just ignore it.

  3. Copy your CodeBreaker.java file into the dbtool folder. You may wish to first use our version, which demonstrates how to implement disk-based hashing.

  4. You'll need to modify your PATH variable to get the files to link properly. To do this:
    1. Right click on My Computer on the Windows desktop.
    2. Choose Properties from the context-sensitive menu.
    3. Click on the Advanced tab.
    4. Click the Environment Variables... button.
    5. Under User Variables, click the New... button.
    6. In Variable Name field, type: PATH
    7. In Variable Value field, type the exact path to your dbtool folder, appending '\build_win32\Release' to the end. NOTE the use of backslashes. The path must be typed exactly as it is, including capitalization, for it to work. For example, let's say your dbtool folder is at h:\dbtool. Then you would type h:\dbtool\build_win32\Release in this field.
    8. Click OK, OK, and OK again to close all the Properties dialogs.

  5. Launch TextPad. If you already had TextPad running, you'll need to quit and relaunch.

  6. You can now open your CodeBreaker.java file in TextPad, and modify it to use the DBToolV class instead of the Hashtable class.

  7. OR: You can run our version of CodeBreaker first, to see how it works. This version of CodeBreaker can be run one of two ways. If you pass it the name of a file on launch, it will use that file to build the disk-based hashtables. If you omit the parameter on launch, it will use not build the disk-based hashtables; it will use the existing ones you previously created. In order to pass a parameter to CodeBreaker on launch in TextPad, you'll need to follow these steps:
    1. In TextPad, choose Configure > Preferences...
    2. Click on Tools, clicking on the plus sign to extend it.
    3. Click on Run Java Application.
    4. Uncheck 'Capture output'.
    5. Check 'Prompt for parameters'.
    6. Click the Apply button, then click the OK button to close the dialog.
    7. Open CodeBreaker.java.
    8. Choose Tools > Compile Java.
    9. Choose Tools > Run Java Application.
    10. In the Parameter field type 'CodeBreaker codefile.txt' and click OK.
    11. It will take a while to build the dictionary file on disk, and then you'll see the Translate Sentence prompt. Proceed to translate sentences, and type quit to stop running CodeBreaker.
    12. The next time you run CodeBreaker, launch it without passing a parameter. To do this, choose Tools > Run Java Application, type 'CodeBreaker' and click OK. This time, it should take no time at all for the program to launch.

Installing Sleepycat for use with Eclipse

  1. Follow steps 1-3 above, except that in step 2 you'll need to copy the dbtool folder to the root of your H drive. (Linking problems may occur later if you initially copy it into your Eclipse\Workspace folder.)

  2. In Eclipse, create a new project, CodeBreakerDisk.

  3. Right-click on the CodeBreakerDisk project and choose 'Import...' from the context-sensitive pop-up menu.

  4. Select File System and click Next.

  5. In the Import dialog, to the right of the blank 'Directory:' field, click the 'Browse...' button, navigate to the dbtool folder, and click OK.

  6. In the window on the right, check CodeBreaker.java, DBTool.java, DBToolV.java, and codefile.txt and leave everything else blank. Click Finish.

  7. Now from the Windows desktop or Windows Explorer, go to the H drive and navigate into the dbtool folder. Drag the build_win32 and com folders onto the CodeBreakerDisk project in Eclipse.

  8. In Eclipse, open CodeBreaker.java.

  9. You can now modify your CodeBreaker.java file to use the DBToolV class instead of the Hashtable class.

  10. OR: You can run our version of CodeBreaker first, to see how it works. This version of CodeBreaker can be run one of two ways. If you pass it the name of a file on launch, it will use that file to build the disk-based hashtables. If you omit the parameter on launch, it will use not build the disk-based hashtables; it will use the existing ones you previously created. In order to pass a parameter to CodeBreaker on launch in Eclipse, you'll need to follow these steps:
    1. First you'll need to do a 'dummy' run of CodeBreaker in order to compile the code and generate the class file. Choose Run > Run As > Java Application. Once you see the Translate Sentence prompt, type quit.
    2. To enter the file name as the parameter for the next launch, choose Run > Run...
    3. In the Main tab, verify that CodeBreakerDisk is the name of the project, and that the main class is CodeBreaker.
    4. In the Arguments tab, type 'codefile.txt' in the Program arguments field.
    5. Click the Run button.
    6. It will take a while to build the dictionary file on disk, and then you'll see the Translate Sentence prompt. Proceed to translate sentences, and type quit to stop running CodeBreaker.
    7. The next time you run CodeBreaker, launch it without passing a parameter. To do this, choose Run > Run... and delete 'codefile.txt' from the Program arguments field. After clicking the Run button, it should take no time at all for the program to launch.


JF KS LZ -- last modified 11/7/02