Problem compiling servlet

I'm having trouble compiling a servlet the uses the org.apache.poi

library. These are the import statements I use:

import javax.servlet.*;

import javax.servlet.http.*;

import org.apache.poi.poifs.filesystem.POIFSFileSys

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.hssf.usermodel.HSSFRow;

import org.apache.poi.hssf.usermodel.HSSFCell;

import org.apache.poi.hssf.util.SheetReferences;

The jar file containing the POI library is called poi-2.5.1-final-20040804.jar

I'm compiling using javac directly, without any IDEs. What should my CLASSPATH environment variable contain to make sure the servlet libraries and the poi libraries are recognized, and do I need to restart the machine so that the changes can take effect? These are the contents of the CLASSPATH variable now:

.;C:\Archivos de programa\Java\jre1.5.0_05\lib\ext\QTJava.zip

these are some of the errors I get:

package javax.servlet does not exist

package org.apache.poi.poifs.filesystem does not exist

The servlet java file is inside the webapp directory:

C:\Archivos de programa\Apache Software Foundation\Tomcat 5.5\webapps\cerberus3\WEB-INF\classes\evenseg\eximport

Any help would be appreciated, thanks.

[1364 byte] By [luisjoseromeroa] at [2007-10-3 1:44:15]
# 1

Jar files need to be inserted into the classpath directly. I see you are using Tomcat, so your classpath should be something like:

.;C:\Archivos de programa\Java\jre1.5.0_05\lib\ext\QTJava.zip;C:\Archivos de programa\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;c:\wherever\poi-2.5.1-final-20040804.jar

(replace wherever with the path to the poi jar file).

This is only for compiling on the command line though, when executing the servlet in Tomcat a completely different classpath is used. You need to copy the poi jar to the WEB-INF/lib directory of your webapplication, if it is not already there.

When I see your current classpath my face starts to twitch because of two reasons:

1) you have a zip file in your classpath. Is this a jar?

2) this file is in the ext directory

Both are NOT recommended practices, keep files that are not packaged with java out of the ext directory.

gimbal2a at 2007-7-14 18:42:24 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks man, big help :) It compiles now. About the zip file. I have no idea what that is :S It was there when I installed the java sdk.
luisjoseromeroa at 2007-7-14 18:42:24 > top of Java-index,Java Essentials,New To Java...
# 3
You'd be much better of using JExcel instead of POI. %
duffymoa at 2007-7-14 18:42:24 > top of Java-index,Java Essentials,New To Java...