Assemble the application: Compile the servlet

After you copy the source code files for your sample application and compiled your enterprise bean files, compile the servlet into a .class file before you can package it into an EAR file and deploy it on your iSeries server.

Follow these steps to compile the servlet:

  1. Enter the Start Qshell (STRQSH) command on an OS/400 command line.

  2. On the Qshell command line, enter this command:

    cd /hcsample

  3. Set the classpath to include the J2EE classes, which are contained in the j2ee.jar file. Enter this command:

    export -s CLASSPATH=.:/QIBM/ProdData/WebAS5/Base/lib/j2ee.jar

  4. Compile your servlet. Enter this command:

    javac HitCount.java

Troubleshooting

If your code compiles with errors, check if the correct Java version is being used. On the Qshell command line, enter this command:

java -version

If it does not indicate the JDK 1.3.x level, you need to explicitly specify the version to use when compiling by entering this command:

javac -J-Djava.version=1.3 /hcsample/com/ibm/defaultapplication/*.java

If you still have compilation errors after checking your Java version, check your classpath. On the Qshell command line, enter this command:

echo $CLASSPATH

The correct classpath is .:/QIBM/ProdData/WebAS5/Base/lib/j2ee.jar. The first period refers to the current directory, and /QIBM/ProdData/WebAS5/Base/lib/j2ee.jar refers to the J2EE APIs.

Continue Next: Package the Web application files