Troubleshooting compilation problemsOnce you start experimenting with code examples from the distribution or writing your own classes, you may need a few tips on the mechanics of compiling and invoking classes. Setting up your PATH and CLASSPATH to compileYou will probably be running your compiler from a shell/DOS window. Check to make sure that you have . . .
For more on setting your CLASSPATH, read Troubleshooting CLASSPATH, another Troubleshooting Tip. Running the compilerOnce your shell/DOS window is properly configured, cd into the directory you want to compile and run the compiler. We'll use the javac (Java compiler) as an example here. The simplest compile command, which compiles a single Java file, is: $ javac filename.javawhere filename is the Java file you want to want to compile. You can use a wildcard (*) to compile an entire directory. Use the -d Java compiler option to set the destination of your compiled files, so that you compile classes into the right directory structure. Here is the pattern: installed directory/weblogic/classeswhere installed directory is the absolute path on your machine to wherever you installed the distribution. For example, to compile the Java file /usr/weblogic/src/examples/dbkona/Query.java use the command: $ cd /usr/weblogic/src/examples/dbkona $ javac -d /usr/weblogic/classes Query.java Invoking a compiled classYou run a Java class by referring to its full package name. A package contains a group of classes (probably related). WebLogic classes, specifically the source code examples shipped with the distribution, are always part of a package. The package is identified on the first line in the class file, for example: package examples.dbkona; All of the code examples shipped with the distribution have package names that match the directory structure from the "examples" level; for example, all the Java files in the examples/dbkona directory are in the "examples.dbkona" package. If the class you are invoking is part of a package, then you must use the package name to run the class. For instance, if the package statement of the Query class is package examples.dbkona, then the class must exist in a file that maps to examples/dbkona/Query.class, and you will invoke the class with this command: $ java examples.dbkona.Query |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|