IJP

Course

Resources


Introduction to Java Programming 2010–2011 — Importing Your Chat Bot into NetBeans for Assignment 2

These instructions are for importing your Assignment 1 chat bot into your Assignment 2 game project in NetBeans 6.7. They assume that you have already worked through the instructions on getting started with NetBeans. They also assume that you are running on an Informatics DICE machine. If not, hopefully this will at least provide useful ideas on achieving the same thing on your own system.

  1. The NetBeans BlueJ plugin doesn't use NetBeans's normal library (jar file) mechanism, so the first thing we need to do is to make the WordNet library available to the NetBeans BlueJ plugin. We do this by copying the WordNet library (jwnl.jar) into a special location in your BlueJ (!) install directory. Run this command from a terminal window (or do it by dragging and dropping among folder windows):
      cp ~/IJPAssignments/IJPAssignment1/lib/jwnl.jar ~/bluej/lib/userlib/
    

    (Remember that in a terminal window, “~” is a shorthand for your home directory.) Obviously this assumes that your Assignment 1 is in ~/IJPAssignments/IJPAssignment1, and that you installed BlueJ in ~/bluej. If you used different locations, then adjust the command accordingly.

  2. Now we need to tell the NetBeans BlueJ plugin to look for user-supplied libraries so it picks up jwnl.jar. Start NetBeans up, and then select the “Options” item under the “Tools” menu. The Options dialogue box should appear. Click on the Miscellaneous tab and then the BlueJ sub-tab. You should see:

    NetBeans BlueJ plugin options dialog

    Browse to the directory in which you installed BlueJ (for example ~/bluej), select that and click OK.

  3. To import your Chat Bot into your Assignment 2 project, the simplest thing is just to copy it in — NetBeans will pick it up. Note that we also need to copy across some critically important directories (jwnl and data) for WordNet. These three commands will work from a terminal window, for example:
      cp -a ~/IJPAssignments/IJPAssignment1/ijp ~/IJPAssignments/IJPAssignment2/
      cp -a ~/IJPAssignments/IJPAssignment1/jwnl ~/IJPAssignments/IJPAssignment2/
      cp -a ~/IJPAssignments/IJPAssignment1/data ~/IJPAssignments/IJPAssignment2/
    

    … as before, you may need to adjust the directory names. You can just as well do this using drag-and-drop between folder windows too: the ijp, jwnl and data directories from your chat bot need to be copied into the IJPAssignment2 directory..

  4. Now if you open your IJPAssignment2 project in NetBeans, you should see something like the following:

    NetBeans project view after importing Assignment 1 into Assignment 2

  5. Open the ijp.assignment1.utils package and then right-click on WordNetWrapper.java. This class has a main method which you can run in order to test that WordNet is working correctly. Select “Run File” from the right-click menu.

    Run WordNetWrapper

    You should see a large amount of text flying past in the Output pane (bottom right of your NetBeans window), finishing with something like this:

      Here are the synonyms for the randomly generated noun correlation
        coefficient_of_correlation, correlation_coefficient, correlation,
        correlational_statistics, correlativity,
      Here are the synonyms for the randomly generated verb pitch
        tilt, huckster, slant, lurch, incline, hawk, sky, gear, deliver,
        cant, peddle, cant_over, vend, slope, monger, set_up, toss, pitch,
        flip, shift,
      Here are the synonyms for the randomly generated adjective primitive
        rude, archaic, untrained, crude, noncivilised, primitive,
        noncivilized, early,
    

    In order to be able to use the “Run File” option, your class must have a main method. main is introduced briefly in 7.15.2 of Objects First with Java; Appendix E talks about this special method in more detail. Your Game class already has one, waiting for you to fill it in…

Hopefully this will have got things working for you — but if not, please don't hesitate to ask someone in a lab.

Version 1.3, 2010/11/23 17:44:42


Home : Teaching : Courses : Ijp : 2010_2011 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh