Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes compiling servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "compiling servlets" Watch "compiling servlets" New topic
Author

compiling servlets

Naveed Ali
Ranch Hand

Joined: Aug 30, 2002
Posts: 41
Hello!
i am new to the servlets world. plz any body answer the following.
1. How to compile servlets from TextPade Or command line?
2. What are the requirements like JDK or JSDK, web server etc?
3. How to configure the relevant paths?
thnx.
Naveed
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
All you need for compiling servlets is the latest sdk from Sun. You could also download the latest version of Jakarta's Tomcat to use as a servlet/jsp container. However, in order to run your servlet successfully, the directory structure that it is placed in has to comply with the servlet 2.3 specification.
Put your classes in a directory structure like this:
WebApplicationDirectory/WEB-INF/classes/com/yourHost/className
(com/yourHost refers to your classes package)
Put your deployment descriptor (web.xml file) like this:
WebApplicationDirectory/WEB-INF/web.xml
If you are using Tomcat, put your WebApplicationDirectory like this:
jakarta-tomcat-4.0.6-LE-jdk14\webapps\WebApplicationDirectory


Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I heartily recommend the ANT tool for compiling servlets. It solves many annoying problems with classpaths by allowing you to define them in a build.xml file. Yes, ANT presents a bit of a learning curve, but you will be glad you did.
Personally I edit/manage servlet projects with UltraEdit-32 and have ANT configured as a tool that can be run from the editor.
Bill
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
The initial post said that the guy was new to servlets and then William recommends learning Ant? Servlets present enough of a challenge to a newbie. Bad advice my friend.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Bad advice my friend.

Completely disagree.
A more-than-trivial number of the questions in this forum, the JSP forum, and the Java in general forums are related to problems doing simple builds. Learning Ant is one of the best steps one can take when setting out to do anything non-trivial with Java -- including servlets.
bear
[ September 26, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
sorry friend..dont misguide urself..
Download the latest jsdk version from the sun site..
for eg:jsdk2.0
before compiling a servlet program at the command line.
set the classpath as follows i have assumed jsdk2.0 folder in the e: drive)
>set classpath=e:\jdsk2.0\lib\servlet.jar;
Now u can compile the servlet as a normal javac command.
But remember that the class file has to be stored in the classes folder.


Thnx
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The initial post said that the guy was new to servlets and then William recommends learning Ant? Servlets present enough of a challenge to a newbie. Bad advice my friend.

I calls 'em like I sees 'em
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Also remember that Tomcat doesnot use the System CLASSPATH while running.
 
 
subject: compiling servlets