Setting your development environment
- Contents
- Introduction
- The development shell
- The setEnv script
- Preparing the setEnv script
- Running setEnv
- What setEnv does
- Setting your environment for type 2 JDBC drivers
- Tips for setting your environment
Introduction
When developing in Java, make sure that you have a controlled
development environment. To avoid class conflicts and other problems that can
be difficult to diagnose, you need to be aware of all of the environment settings that you use during development.
The CLASSPATH environment variable is very important as it is used by
the java and
javac commands to locate the Java classes
that are required to run applications and compile source files. It is imperative that CLASSPATH contains the appropriate classes for compiling and running your applications. For more
information, see Setting classpath.
This document discusses the use of the sentEnv
shell script to ensure that CLASSPATH and other environment variables are
set properly and consistently for your development work. This document does not discuss setting up the environment for running the server. This is discussed in Setting up and starting WebLogic Server.
The development shell
A development shell is a command line shell that you create for the purpose
of compiling and running the examples shipped with WebLogic or for your own development.
To be certain that this shell has the appropriate
environment variable settings, run the setEnv
script within the shell.
The setEnv script
Scripts for setting up your development shell are included in the root
directory of your WebLogic distribution. There are scripts for UNIX
(setEnv.sh) and Windows NT
(setEnv.cmd). Running these
scripts sets up environment variables properly for compiling and
running the examples.
Preparing the setEnv script
Before you run setEnv,
load the script in a text editor and check that it has the correct
settings for your installation. Specifically, you should check the
settings of two enviornment variables: JDK_HOME and
WL_HOME.
Depending on your platform and other environment considerations,
there are other changes you make need to make in the script:
- Edit the JDK_HOME variable.
To specify a Java Developers Kit (JDK) for your development work, edit the
setEnv script so that the
JDK_HOME variable points
to the directory where the JDK
you want to use is installed. For
example, if you are using Windows NT and you plan to use the JavaSoft
Java 2 JDK version 1.2.1 for development, edit the setEnv.cmd file and change the set JDK_HOME line to point to the directory where
you installed the Java 2 SDK. For example:
set JDK_HOME=c:\jdk121
If you are using UNIX and you have installed a JavaSoft JDK version
1.1.7 in the /usr/local/java/jdk117 directory, you would edit setEnv.sh and set the JDK_HOME variable as in this example:
set JDK_HOME=/usr/local/java/jdk117
- Important: If you use Microsoft SDK for Java, be sure to read
Tips for setting up your environment below. There are some
differences between the Microsoft SDK and SDKs based on the JavaSoft reference
implementation.
For more information on which JDKs are supported with WebLogic Server, see WebLogic platform support.
- Edit the WL_HOME variable.
The WL_HOME environment
variable points to the directory where you installed WebLogic Server.
This is the same directory where the setEnv script is found. If you installed WebLogic
Server on Windows NT using the InstallShield distribution, this
variable is set automatically. However, if you installed with the zip
file distribution, you must set this variable to the full
pathname of your WebLogic installation. Here is an example for a UNIX
computer with WebLogic Server installed in the /home/u/weblogic directory:
set WL_HOME=/home/u/weblogic
-
If you are using UNIX, make sure the setEnv.sh
script is executable by running the following command:
chmod +x setEnv.sh
Running setEnv
You can run the setEnv script
from any directory within a command shell by including the full path
to the WebLogic root directory, as shown in the following command for
Windows NT:
$ \weblogic\setEnv
where weblogic
is the directory where WebLogic is installed.
On UNIX, run the script in a Bourne shell (or a compatible shell
such as bash) with the command:
$ . /weblogic/setEnv.sh
where weblogic
is the directory where WebLogic is installed. The ". " ensures that the variables set by setEnv are retained by the command
shell after the script is run.
What setEnv does
SetEnv sets the following environment
variables in your development shell:
- CLASSPATH -- contains all of the classes required to compile and run the examples
- CLIENT_CLASSES -- points to the directory used to store client classes
- SERVER_CLASSES -- points to directory used to store server-side classes
- SERVLET_CLASSES -- points to the directory used to store servlet classes
- PATH -- appends the JDK and WebLogic bin directories
CLASSPATH
SetEnv sets CLASSPATH in your
development shell to include all of the classes necessary to compile
and run the examples.
- /weblogic/classes
- /weblogic/lib/weblogicaux.jar
- /weblogic/license
- /weblogic/myserver/clientclasses
- /weblogic/myserver/serverclasses
- JDK classes.zip, when appropriate
where weblogic is the directory
in which WebLogic is installed. The
/weblogic/myserver/serverclasses path is added
only because it is required during compilation by some examples where multiple server-side classes
are dependent on or reference each other. The JDK classes.zip is added only when using
JDK 1.1.7 or Microsoft SDK for Java. Microsoft users should see
Tips for setting your environment for additional information.
The script overwrites anything that is currently in
CLASSPATH. If you would like to run other Java applications or tools from within your
development shell, you must edit the set CLASSPATH
command in the setEnv script to include
any classes that these applications
may require.
Target variables
SetEnv sets three target variables:
CLIENT_CLASSES, SERVER_CLASSES, and
SERVLET_CLASSES. These variables can be
used in conjunction with the -d
option of the javac command to
place the resulting compiled class in the appropriate
directory.
Under the /weblogic/myserver directory,
you will find three directories intended for storing the classes generating
from your own development efforts and from the examples shipped with WebLogic.
These directories are:
- /clientclasses -- for classes required by client applications
- /serverclasses -- for classes required by server-side objects
- /servletclasses -- for servlet classes
The syntax for accessing environment variables is different between
Windows NT and UNIX.
For Windows NT, variables are accessed by bracketing the
variable name with "%" characters as shown below:
$ javac -d %CLIENT_CLASSES% Client.java
For UNIX, variables are access by preceding the variable name
with the "$" character as shown below:
$ javac -d $CLIENT_CLASSES Client.java
Both of the commands above result in the compiled class being placed in the
weblogic/myserver/clientclasses
directory, where weblogic is the
directory where WebLogic is installed.
Setting your environment for type 2 JDBC drivers
Using a WebLogic type 2 JDBC driver as a client requires an additional
entry to your PATH variable. For Windows NT, set your PATH to include
/weblogic/bin. For instructions on setting your shared library
path on UNIX systems, see Installing JDBC
Drivers.
If you will be using a type 2 JDBC driver in a three-tier
architecture, also modify the PATH (as described above) you use to start
WebLogic Server.
Tips for setting your environment
- You should never have a system classpath set. You should be able to
open a new shell, type set classpath and not have any variable set. This
will prevent classpath conflicts.
- Some Windows NT installation programs for JDKs place a copy of
java.exe or jview.exe in \winnt\system32, which causes that command to superceed any
other you may have installed. If you need to switch JDKs you should be
aware that this copy exists. You can use another JDK by specifying it
with the JDK_HOME variable,
and then running the setEnv
script. For details, see Selecting a JDK .
- If you are using Microsoft SDK for Java and building and deploying
EJBeans, you must install a JDK from Sun so that you have access
to the jar tool, which is required for building EJBeans. Please see
the note on this in the Examples Guide Building Enterprise
JavaBean examples.
- If you are using Microsoft SDK for Java, you must run the
clspack utility included with the SDK
before attempting to use WebLogic tools such as the RMI compiler and COM compiler.
By default, the SDK stores its Java packages internally. The
clspack utility writes these packages to a zip file
which can then be added to CLASSPATH and referenced by the WebLogic tools. To run the
utility, enter the following in a command line shell:
$ c:\winnt\clspack -auto
This creates c:\winnt\java\classes\classes.zip.
