aspose file tools*
The moose likes Beginning Java and the fly likes Compiling a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling a servlet" Watch "Compiling a servlet" New topic
Author

Compiling a servlet

Rajive Gayan
Greenhorn

Joined: Nov 07, 2006
Posts: 1
hi im new to the servlet world. I started studing for SCWCD but I cant compile the first example in HF chapter 1 please tell me how to compile a servlet java code Thanks
Sagar Birari
Greenhorn

Joined: Sep 05, 2008
Posts: 11
You can compile servlet as normal java file..
explain your exact problem

Regards


Sagar Birari
Development & Technical Blog
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

Rajive,
The first step is to get a copy of the servlets.jar or j2ee.jar. It should come with your server - for example Tomcat or JBoss.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Giovanni De Stefano
Ranch Hand

Joined: Aug 17, 2004
Posts: 144
Hello

try to give a look here

I assume you followed the instructions on the book.

Basically, if you are compiling from a command line under Windows, you need to know the following folders:

1) where Tomcat is installed (let's assume "c:\Program Files\Tomcat\")
2) where your Project is (let's assume MyProjects\beerv1)

and make sure that JAVA_HOME is set and its bin folder is in the PATH (to check this type echo %JAVA_HOME% and echo %PATH% or simply type javac from the command line and you should get someting).

Once you know this, then you have to:

1) cd MyProjects\beerv1
2) javac -classpath "c:\Program Files\Tomcat\common\lib\servlet-api.jar:classes:." -d classes src\com\example\web\BeerSelect.java

Once you get to the 3rd version, just remember that BeerSelect.java depends on BeerExpert.java, thus you have to compile first BeerExpert and then BeerSelect.

I hope this helps.

Giovanni


SCJP 1.4
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61412
    
  67

Have you read through the FAQ entry for this subject?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi Rajive Gayan welcome to Javaranch ,

The FAQ entry Bear is talking about can be found here .
Just to check whether all things are in place(that means your server) try experimenting with the CodeBarnSimpleServlet .
If you see "Hello, World" then as Giovanni says, you need to follow the steps in his post to make your servlet compile and run.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiling a servlet