eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Web Programming
Packages  
  • Although classes are the central unit ofobject-oriented design in Java, packages provide an additional level of organizational support. Packages are used to store setsor related classes and interfaces. (packages usually correspond to a directory in which you store your class files). As such,packages define relationships between classes and how they should work together. They also protect the name space sincethey provide the JVM another way to identify classes by name. Thus, you may have two classes of the same name so long as they reside in separate packages.

  • You can specifically define a package name using the "package" keyword on the first line of aclass such as in:

    package myPakage;

  • Another benefit of using packages is it allows you to refernce entire packages of classes using the "import"keyword. Thus, rather than specifying a class absolutely, youcan import its package and reference it relative to its package.Thus, you often see the line:

    import java.awt.*;

  • In this case, you can use any class inthe awt package using only its name. Consider the following code:

    import java.applet.*;
    public class myApplet extends Applet
      {
      .. code...
      }
    

  • Without the import, you would need to write the following:

    public class myApplet extends java.applet.Applet
      {
      .. code...
      }
    

    Note that you get all the classes in java.lang for free since it isloaded automatically by the JVM

  • Relationships between classes arealso handled by modifiers or access specifiers. We'll talkabout this in just a minute.

Previous Page |Next Page