BEA Logo BEA WebLogic Server Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

Troubleshooting compilation problems

Once 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 compile
Running the compiler
Invoking a compiled class

Setting up your PATH and CLASSPATH to compile

You will probably be running your compiler from a shell/DOS window. Check to make sure that you have . . .

  1. A Java compiler in your PATH. If you are using the JDK, you will need to make sure that the java/bin directory is in the PATH of your machine, and particularly in the PATH of the shell from which you are using the compiler.

  2. Java classes in your CLASSPATH. If you are using the JDK, make sure that the java/lib/classes.zip file is in your CLASSPATH -- and in the CLASSPATH in the shell from which you are running the compiler.

  3. WebLogic classes in your CLASSPATH. The absolute path of the directory where you installed the WebLogic distribution, most likely ending in "weblogic/classes", should also be in the CLASSPATH of the shell from which you are running the compiler.

For more on setting your CLASSPATH, read Troubleshooting CLASSPATH, another Troubleshooting Tip.

Running the compiler

Once 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.java
where 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/classes
where 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 class

You 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.
Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.
Last updated 01/14/1999