BEA Logo BEA WebLogic Server Release 5.0

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

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

Top of the page

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.

Top of the page

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.

Top of the page

The setEnv script

Scripts for setting up your development shell are included in the root directory of your WebLogic distribution. There are two scripts:

setEnv.sh For a UNIX bourne shell. Because of the differences between UNIX shells, this script is supported on a bourne shell on UNIX only.
setEnv.cmd For Windows NT. This script is to be run in a DOS command shell.

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: JAVA_HOME and WL_HOME. Depending on your platform and other environment considerations, there are other changes you make need to make in the script:

  1. Edit the JAVA_HOME variable.

    To specify a Java Developers Kit (JDK) for your development work, edit the setEnv script so that the JAVA_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 JAVA_HOME line to point to the directory where you installed the Java 2 SDK. For example:

      set JAVA_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 JAVA_HOME variable as in this example:

      set JAVA_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.

  2. 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

  3. 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
If using JDK 1.2, the follwing will also be added:
  • /jdkHome/lib/tools.jar
If using JDK 1.1.7, the following will also be added:
  • /jdkHome/lib/classes.zip
If using Microsoft SDK for Java, the following will also added:
  • /winnt/java/classes/classes.zip
  • /weblogic/lib/rmiForMs.zip
where weblogic is the directory in which WebLogic is installed and jdkHome is the directory in which your JDK 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. 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.

Top of the page

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 instructions on setting your PATH (Windows NT) or load library path (UNIX), 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.

Top of the page

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 JAVA_HOMExz 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.

 

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 09/29/1999