aspose file tools*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting a servlet file to compile" Watch "Getting a servlet file to compile" New topic
Author

Getting a servlet file to compile

sudhan Sadanand
Greenhorn

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
Rancher

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
Greenhorn

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
Greenhorn

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: 193
why not using some IDE like eclipse.....it will make the life simpler.....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Originally posted by ajse roy:
why not using some IDE like eclipse.....it 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.


Ping & DNS - my free Android networking tools app
 
wood burning stoves
 
subject: Getting a servlet file to compile