2

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~

Community
  • 1
  • 1
Scott
  • 103
  • 1
  • 1
  • 10

6 Answers6

1

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.

Maruti
  • 61
  • 1
  • 3
0

Right Click on MyComputer->Properties->Advanced->Environment Variables->

Set a new user variable name as classpath and give the variable value where your servlet-api.jar file is located (applicable for tomcat webserver), for example:->

variablename: classpath

variablevalue: D:\Tomcat\lib\servlet-api.jar

Now you can run your disassembler to find out the servlet class and interface information

0

If you are not able to load the servlet package, try setting the environment variable CLASSPATH to .;C:\tomcat\common\lib\servlet-api.jar. That should help.

Anvita Shukla
  • 409
  • 7
  • 7
0

Ok!.. i bought a new laptop and was faced the same problem, well i hope this would fix the issue on your windows 10 device as well.

First of all know that the error is just due to incorrect or incomplete path or classpath. After Installing Tomcat and JDK set the environment variable as follows(Location may vary as per your installation):

JAVA_HOME = C:\Program Files (x86)\Java\jdk1.7.0_80

JRE_HOME = C:\Program Files (x86)\Java\jre7

CATALINA_HOME = C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0

PATH = C:\Program Files (x86)\Java\jdk1.7.0_80\bin; C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\bin;

CLASSPATH = C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar; C:\Program Files (x86)\Java\jdk1.7.0_80\lib\tools.jar; JAVA_HOME\lib

make sure that your classpath directs the mentioned jar files, as javax is included in it(try using winrar for checking the inner contents).

After saving the setting, Test using javap javax.servlet.Servlet

Well if you still face any issue please share the error message and screenshot.

Ronit Oommen
  • 3,040
  • 4
  • 17
  • 25
0

Right Click on MyComputer->Properties->Advanced->Environment Variables->

Set a new user variable name as classpath and give the variable value where your servlet-api.jar file is located (applicable for tomcat webserver), for example:->

variablename: "CLASSPATH"

variablevalue: D:\tomcat\lib\servlet-api.jar;.

Then Check Open Command and Type :- C:\Users\akash>javap javax.servlet.Servlet

small error because javax old version Error: class not found: javax.servlet.Servlet

Then Check Open Command and Type :- C:\Users\akash>javap jakarta.servlet.Servlet

This should work fine.

-1

Probably because Tomcat is not in the Java Build Path. Try add Tomcat to your library

1) Right-click on your project folder > Build Path > Configure Build Path

2) Click on Library tab > click Add Library button

3) Select Server Runtime > click Next button

4) Select your server > click Finish button

An economist
  • 1,301
  • 1
  • 15
  • 35