File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Getting a servlet file to compile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting a servlet file to compile" Watch "Getting a servlet file to compile" New topic

Getting a servlet file to compile

sudhan Sadanand

Joined: Jul 25, 2006
Posts: 4
Im just starting out on servlets. Downloaded the j2ee sdk5 from the sun website and installed it. Wrote the first program from the K&B book and when i tried to compile it using javac it throws me 5 errors saying
package javax.servlet, HttpServletRequest,HttpServletResponse not found. What could be wrong.

I tried setting the class path all over again. still no use. other j2se files compile fine and i have a problem only with this file

What do i do?

◄ Sudhan ►
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

you need to include either j2ee.jar or servlets.jar on your classpath.

the JEE jar contains all of the required classes including servlets and ejbs, servlets just has the servlet and JSP stuff.
sudhan Sadanand

Joined: Jul 25, 2006
Posts: 4
Ya thanks... ran a search on that and found out how to get it done. Finally the code compiled n ran properly...
But is there an easier way out of this. I mean,can the .jar file be permanently included in the path rather than us having to type it manually everytime?
prateek chaudhari

Joined: Oct 14, 2006
Posts: 11
Yes! In windows enviornment you can copy the .jar file location directly to the CLASSPATH system variable so that you dont need to include them again and again.

YOu need to

goto control panel->system->select advanced Tab under this you will find 2 buttons at bottom side of the dialog click on enviornment variables->select the CLASSPATH varible from system varibles list if it is not there then create one and insert the location of the .jar file, now its done!

Prateek<br />SCJP 1.5
ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196
why not using some IDE like will make the life simpler.....
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
Originally posted by ajse roy:
why not using some IDE like will make the life simpler.....

That's debatable. For a beginner I usually recommend not using an IDE, because they require the user to understand a lot of things that won't make sense to beginners.
I agree. Here's the link:
subject: Getting a servlet file to compile
It's not a secret anymore!