Processing Java servlet 'javax.servlet' package not found

Scott picture Scott · Jan 11, 2011 · Viewed 12.7k times · Source

Not a very common implementation, but using Processing as a Java Servlet has been discussed in previous posts before (1, 2). I have been developing a program in Processing to use as a Java servlet. However, when I have code (such as like the first linked example) in a Processing sketch, I get the error message

The package 'javax.servlet' does not exist.  You might be missing a library.

I have Tomcat 5.5 service running on XP, and my environment variables are as follows

CLASSPATH = C:\tomcat\common\lib\servlet-api.jar
CATALINA_HOME = C:\tomcat
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_21
JRE_HOME  = C:\Program Files\Java\jre6

I have been trying to diagnose why the javax.servlet packages are not recognized by Processing for many hours and there is nothing online that seems to yield an explanation other than fixing the environment variables to recognize the tomcat libraries. I have also tried to put the servlet-api.jar and jsp-api.jar files in Processing as a kind of custom Processing library but they are not recognized there either, nor when I try to run the program within the tomcat/webapps folder.

I also have tried

javap -classpath my;class;path javax.servlet.Servlet

on the cmd and it gave me the same error.

I'm not that good with Tomcat yet so please forgive me if this is a result of my unfamiliarity. If anyone more knowledgeable than I can shed some light as to why Processing cannot recognize this package would be tremendous. Thanks so much~

Answer

Maruti picture Maruti · Jan 13, 2011

CLASSPATH = C:\tomcat\common\lib\servlet-api.jar

This is the problem . Your classpath should be one level up i.e

CLASSPATH = C:\tomcat\common\lib\

This should work fine.