• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling a servlet

 
Rajive Gayan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can compile servlet as normal java file..
explain your exact problem

Regards
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Giovanni De Stefano
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read through the FAQ entry for this subject?
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic