Adding cputils to Your Project

Background

The cputils library contains a class called FileUtils that provides methods for reading and writing data from text files.

This document shows you how to add the library to your NetBeans project.

 

Instructions

Create a New Project or Open an Existing Project

Before adding cputils your project might look something like the following. Take note of both the "Projects" tab and the "Files" tab.

Step 1 (Optional) - Copy cputils to Your Project Folder

(This step is not actually required, but it is recommended. If you do this, then if you switch to a different computer, you won't have to update the link to the library.)

  1. Download and unzip the cputils package. You will see a folder called "cputils". Inside the folder, there is a file called "cputils.jar" and another file called "javadoc.zip".
  2. Copy the entire folder and paste it in the Files tab of your project.
  3. You will see the folder in the Files tab, but NOT in the Projects tab.

Step 2 - Add cputils as a Library in your project

  1. In the Projects tab, right-click on Libraries and select "Add JAR/Folder".

  2. A window will appear. In this window, browse to your project folder, then the cputils folder, and select "cputils.jar".
    • Make sure you select the copy of "cputils.jar" that is inside your project folder.
    • Make sure that "Relative Path" (not "Absolute Path") is checked.

    You should now see "cputils.jar" under the Libraries node in the Project tab.

    (If you want to add the documentation so that it will popup automatically in your code, perform the next two sub-steps (steps c and d); otherwise, proceed to the next major step(Step 3).)

  3. Right-click on "cputils.jar" in the Libraries node and select "edit".

  4. A window will appear. In the "Javadoc" field, browse to the same folder where "cputils.jar" is and select the "javadoc.zip" file. When you are done, press OK. (You won't see any change in the Projects tab, but the documentation will be available in your code.)

Step 3 - Import FileUtils in your Code

(This is the same as importing other classes like java.util.Scanner or javax.swing.JOptionPane.)

  1. At the top of the class, below the package statement, type "import cputils." ... FileUtils will popup as the only choice, and if you added the Javadocs, you will see a description of the class.

  2. Select FileUtils and add a semicolon to complete the import statement.
  3. Now you can call the FileUtils methods in your code. And if you added, the Javadocs, you will see the documentation for each method.


*** THE END ***