Java Reference
In-Depth Information
// Create a new ErrorMsg object. Specify the full package name.
java4cobol.messages.ErrorMsg accountNotFound =
new java4cobol.messages.ErrorMsg ();
...
// Copy the msgText from the ErrorMsg class to the local ErrorMsg String
// variable.
ErrorMsg = java4cobol.messages.ErrorMsg.getErrorMsg();
}
P ACKAGES AND F ILENAMES
Java packages and the directories on your computer's file system are closely related.
As a rule, any package name must have a corresponding directory name on the host
operating system, and it is case sensitive. This applies to both the development en-
vironment and the runtime (deployment) environment.
The name of a package maps to its filename location. In this example, you would
expect to find a directory named ..\java4cobol\messages and ..\general_ledger
(on UNIX systems, the slashes go the other way: .. /java4cobol/messages and ..
/general_ledger). Notice that the introductory periods (..) in the package names
( java4cobol.message ) are replaced with the correct directory separator character
(java4cobol\message or java4cobol/message).
The package name does not normally start at the root directory of the host file
system. Instead, Java uses the CLASSPATH variable to point to a list of initial di-
rectory names, which are then searched for specific package directory names as
well as class names.
In the example, if you set CLASSPATH to c:\windows\java; c: , the compiler will
look in both the C:\windows\java directory and the root directory of the C: drive
for a directory named java4cobol\messages. In this directory, it will look for a file
named ErrorMsg.class.
It is likely that you will use packages from other vendors, or perhaps you will cre-
ate packages that some other development or deployment environment will use.
Since it is not realistic to coordinate class names or package names in advance, a con-
vention is often used to group packages based on the origin of the package. Many
package names are prefixed with the Internet address (domain name) of the provider,
but in reverse order. Sometimes the .com portion of the domain name is left out.
For example, if an organization's domain name is mycompany.com, the
java4cobol.message packages delivered by this company will likely be in a directory
named com.mycompany.java4cobol.message, or mycompany.java4cobol.message.
Search WWH ::




Custom Search