Walkthrough: AWS: Java Code Sample: Step 3

Step: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | N

3) Update your CLASSPATH to include an explicit reference to each Axis JAR file

The all important CLASSPATH gets its own separate step in the list of instructions because this environment variable is as important as the PATH environment variable. The CLASSPATH is the list of directories and/or JAR files that Java will use to find classes and other resources.

The instructions state that each Axis JAR file needs to be in the CLASSPATH. Here are the JAR files in the Axis lib subdirectory:

% pwd
/home/Rick/Java/axis-1_1/lib

% ls -1
axis-ant.jar
axis.jar
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
log4j-1.2.8.jar
saaj.jar
wsdl4j.jar

I've discovered that you do not need to have the axis-ant.jar file in your CLASSPATH.

Probably the easiest way to set the CLASSPATH is through a shell script or DOS batch file. Let me show you the DOS version first. I have all these lines in a file called setup-classpath.bat:

REM setup-classpath.bat
REM
REM script to initialize the CLASSPATH for the Amazon application. This file
REM is meant to be executed on the DOS command line.

SET CLASSPATH=.

REM This is the XML Parser, used for SOAP and AXIS
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\xerces-1_4_4\xerces.jar

REM Add AXIS
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\axis.jar
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\jaxrpc.jar
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\commons-logging.jar
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\commons-discovery.jar
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\wsdl4j.jar
SET CLASSPATH=%CLASSPATH%;C:\cygwin\home\Rick\Java\axis-1_1\lib\saaj.jar

For Cygwin, my BASH script looks like this:

#
# setup-classpath.source
#
# script to initialize the CLASSPATH for the Amazon application. This file MUST
# BE sourced (or ".") in the current BASH shell

CLASSPATH="."

# This is the XML Parser, used for SOAP and AXIS
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\xerces-1_4_4\xerces.jar"

# Add AXIS
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\axis.jar"
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\jaxrpc.jar"
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\commons-logging.jar"
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\commons-discovery.jar"
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\wsdl4j.jar"
CLASSPATH="$CLASSPATH;C:\cygwin\home\Rick\Java\axis-1_1\lib\saaj.jar"

export CLASSPATH

Now whenever you need to compile or run the Java code in the JavaCodeSample, execute one of these scripts (depending on whether you're on DOS on Cygwin) and the CLASSPATH will be set correctly.

Next
Step: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | N


Rick (rgu@TheWorld.com) Umali
Last Update: 2/24/2004