Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Compiling Servlets

AKA:
Why was my question about compiling servlets moved from the servlets forum to the Beginning Java forum?

Servlets are nothing more than Java classes with some dependencies.
They are dependent on libraries in the javax.servlet and javax.servlet.http packages.

All of these libraries are present in j2ee.jar which can be downloaded from http://java.sun.com.

Some servlet containers ship with a sub-set of the J2EE libraries; making it unnecessary to download j2ee.jar separately.
For instance, if you're using the Tomcat Application server the libraries can be found in TOMCAT_INSTALL_DIRECTORY/common/lib/servlet-api.jar (in older versions, it's called servlet.jar), or TOMCAT_INSTALL_DIRECTORY/lib/servlet-api.jar for versions above 6.0. Take a look to see which one you have.

Once you have located the jar file that needs to be added to your classpath, proceed to HowToSetTheClasspath to learn how to set up your classpath in order to compile your Java classes.




If the question is about compiling servlets, isn't the servlets forum the best place to get an answer?

No.
Servlet programming, like Swing programming, Javamail programming, or any other sub-set of Java is still Java programming. Like with any of these other technologies, a working understanding of Java fundamentals is needed if you want to learn servlets quickly. Ideally, someone having trouble compiling their servlet will decide that they aren't ready to tackle servlets yet, step back, and solidify their understanding of javac, packages, and the concept of the classpath by reading a book or tutorial on Core Java, then come back to servlet programming. Too often, however, people think that it will be easier to skip right to servlets and end up becoming very frustrated when it takes a long time just to get things to compile.

In any case, our Beginning Java forum is the best place to go if you're having trouble getting a Java class (servlet or otherwise) to compile. The folks there have taken the time to write some excellent FAQ entries to get you up to speed and, there, you will find plenty of other threads started by people who are having similar issues getting their Java classes to compile. Often , you can find the answer just by skimming other threads and finding out how other people managed to solve the same problem you're having.
 
Tell me how it all turns out. Here is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    Bookmark Topic Watch Topic
  • New Topic