Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting a servlet file to compile

 
sudhan Sadanand
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not using some IDE like eclipse.....it will make the life simpler.....
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic