The information in this article applies to:
SUMMARYWhen the Visual J++ compiler, Jvc.exe, sees a package statement, it automatically creates the directory structure needed for the package declared. The .class files that define the classes in the package must be placed in this directory structure. By default, they are not placed in the correct directory. You must specify an output directory to tell the compiler where to place the .class files. MORE INFORMATION
The .class files that define the classes in a package must be placed in a
directory that matches the package name. For example if you were to define
a package called "animals.dogs," the .class files that define the classes
in this package must be located in the "animals\dogs" directory.
The resulting class files are placed in this directory.
When compiling a class file that imports a package, the compiler searches the directories in the classpath for a directory that matches the name of the imported package. It then looks in that directory for the class files that define the class. If the class file cannot be found, the compiler gives J0049 (Undefined Name) and J0044 (Cannot find definition for class) errors. Note that only the top-most directory in a package directory structure must be in a directory that's listed in the classpath. Continuing on with the animals.dogs sample, only the directory that contains the animals directory must be listed in the classpath (that is, c:\msdev\projects\packtest must be in the classpath). Once the compiler finds the animals directory it knows how to find the .class files in the subdirectories of animals. When searching for directories, Microsoft Developer's Studio (MSDEV) makes sure that the current project directory appears in the classpath. When running an application or an applet, the Microsoft virtual machine similarly searches the classpath for the needed .class files. Since the root directory of the package hierarchy must be in the classpath, it's a good idea to have a central location for all packages. When you installed Visual J++, one was created for you:
This directory is automatically included in the classpath. If you choose
not to use a central repository, each time you create a package, you must
add an additional entry to your classpath.
REFERENCESFor the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following pages on the Microsoft Technical Support site: http://support.microsoft.com/support/visualj/ Additional query words:
Keywords : kbusage kbCommandLine kbGenInfo kbVJ kbVJ100 kbVJ110 |
Last Reviewed: November 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |