Creating Packages - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Creating Packages

Description:

The first compilation creates the directory structure and ... Subsequent compilations just place the class file for PgmName at the bottom. Using A Package ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 6
Provided by: paulde8
Category:

less

Transcript and Presenter's Notes

Title: Creating Packages


1
Creating Packages
2
CLASSPATH
  • Set the CLASSPATH environment variable
  • Directs the Java Class Loader to begin search at
    the directory that contains the package directory
    structure
  • My package directory structure is located in
  • /home/winnt/GONZAGA/depalma/public_html/courses/cp
    sc324/packages
  • in .profile of my home directory, I have
  • CLASSPATH/home/home/winnt/GONZAGA/depalma/public
    _html/courses/cpsc324/packages

3
Package Directory Structure
  • By Convention, the package directory structure is
    your server name followed by the name of the
    package
  • So, I have a package called containers
  • located at CLASSPATH/edu/gonzaga/cs/containers

4
Creating the structure
  • Beginning with the lowest level class member in
    the package
  • Make this the first
  • package ltpackage directory structuregt
  • In my case, this is
  • package edu.gonzaga.cs.containers
  • 2. Compile with the d option
  • javac d . ltPgmNamegt.java
  • The first compilation creates the directory
    structure and places the class file for PgmName
    at the bottom. Subsequent compilations just place
    the class file for PgmName at the bottom

5
Using A Package
  • Put this line at the top of each program that
    uses a class in the container
  • Import ltpackage directory structuregt.ltclassNamegt
  • Suppose I want to use List.class
  • import edu.gonzaga.cs.containers.List
Write a Comment
User Comments (0)
About PowerShow.com