how to compile servlets in JEE 5 SDK

N

Naeem

I have installed JEE5 with JDK on windows. When I compile a servlet
using 'javac', it gives the error that javax.servlet package does not
exist. I have tried by adding path of j2ee.jar file in classpath
environment variable (classpath variable doesn't exist, i have created
one) and even tried to copy j2ee.jar file in jdk\jre\lib\ext folder
but no results. Should i need to install JSDK or jee 5 sdk can compile
the servlets. if so how?
Please help....
Thanks.
 
T

Tymoteusz Gedliczka

Naeem said:
I have installed JEE5 with JDK on windows. When I compile a servlet
using 'javac', it gives the error that javax.servlet package does not
exist. I have tried by adding path of j2ee.jar file in classpath
environment variable (classpath variable doesn't exist, i have created
one) and even tried to copy j2ee.jar file in jdk\jre\lib\ext folder
but no results. Should i need to install JSDK or jee 5 sdk can compile
the servlets. if so how?
Please help....
Thanks.

You need to add servlet-api.jar to your buildpath. If you use Tomcat
then it's located in lib subdirectory of your Tomcat installation.

I haven't used other containers, but I guess they provide this jar as
well, just look for it.
 
N

Naeem

You need to add servlet-api.jar to your buildpath. If you use Tomcat
then it's located in lib subdirectory of your Tomcat installation.

I haven't used other containers, but I guess they provide this jar as
well, just look for it.

I am not using Tomcat but Java APP Server. I guess this file is
j2ee.jar but how and where to copy it?
 
R

ruds

Try downloading the servlet.jar file from java.sun.com and put it in
lib folder of your sdk.
Add this path to your evironment variable CLASSPATH. And then try
compiling your servlet
 
L

Lew

ruds said:
Try downloading the servlet.jar file from java.sun.com and put it in
lib folder of your sdk.
Add this path to your evironment variable CLASSPATH. And then try
compiling your servlet

It won't work. Toncat, Sun's server and all the others of which I know ignore
the CLASSPATH envrionment variable.

Even programs that don't should have their classpath set in the invocation,
not in the environment variable.

The OP has /already/ downloaded the necessary JARs if they've correctly
installed Sun's application server.

To the OP: Read the documentation that comes with the app server. It will
explain how to deploy applications, which is the process you need. I use the
application server's admin task (installed to monitor port 4848 by default) to
deploy applications.

Read the documentation. Ignore specious advice about downloading servlet.jar
or j2ee.jar or whatever, or about CLASSPATH, and use the techniques built into
the app server.
 
L

Lew

ruds said:
Try downloading the servlet.jar file from java.sun.com and put it in
lib folder of your sdk.
Add this path to your evironment variable CLASSPATH. And then try
compiling your servlet

The OP has /already/ downloaded the necessary JARs if they've correctly
installed Sun's application server.

Also, the CLASSPATH envar is not the only way to specify class paths. It is
the least flexible method. One can use command-line options to set the class
path more flexibly.

To the OP: Read the documentation that comes with the app server. It will
explain how to build and deploy applications, which is the process you need.
I use the application server's admin task (installed to monitor port 4848 by
default) to deploy applications.

If you aren't using an IDE to build your app, use Ant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top