Downloading Jars

In this course you must frequently download collections of files for use in labs and assignments. We're going to use jar, or Java archive, files for this purpose in CSCI 201.

In each lab, you will typicaly be given a link to a Jar archive such as this link to the archive file Tryit.jar. Depress the shift key and right-click on the link, to Save the file to your hard drive. Save the file in your csci/201 folder. Although Netbeans offers jar file extraction capabilities, it is easier to use Sun's jar file extractor. To do so, give the following commands in your Linux session window:

[user@mach dir] cd csci/201
[user@mach dir] jar xfv Tryit.jar
  created: META-INF/
  inflated: META-INF/MANIFEST.MF
  created: Tryit/
  inflated: Tryit/TryIt.java

In the first command, cd csci/201, we are setting our current working directory to be csci/201, the directory containing the archive file Tryit.jar. The command jar xfv Tryit.jar unpacks or "expands" the archive file.

Give the command ls -R (dir in windows) to see the directory (and its contents) created by unpacking the archive file.

[user@mach dir] ls -R

Opening the File

To see the contents of the java file that you just downloaded, you need to open it in Netbeans:

  1. If netbeans is not already running, give the command to start Netbeans in your Linux session window.
    [user@mach dir] netbeans &
    
    
  2. If you have a Netbeans project open and you want to save that project for future work, then create a new project for the TryIt program.
  3. Mount the TryIt directory. (In lab, always mount the directory containing the java file that you'll be working on.)
  4. Open the file in Netbeans' editor by double-clicking on it in Netbeans' explorer window.
  5. Make sure that you can compile and execute the program---don't worry about the odd output.

Applets

There is one more step that is required if the jar file contains an applet. Keep in mind that TryIt is not an applet; this information is being provided for future reference only. In order to compile and run an applet correctly, you will need to tell Netbeans that it is an applet. To do this:

  1. Right click the file in Netbeans' Explorer window
  2. Select Properties
  3. Click the Execution tab at the bottom
  4. For the debugger field, select Applet Debugging
  5. For the executor field, select Applet Execution