• Post Reply Bookmark Topic Watch Topic
  • New 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To Compile Servlet

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In chapter3 page 81.
---------------------
javac -classpath /User/bert/Application2. Which path is this.Its written adjust to match your own directory path to your sysytem
I have created my development environment in C:\MyProjects\beerV1 and deployment environment as
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Beer-v1.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by satya mahapatra:
In chapter3 page 81.
---------------------
javac -classpath /User/bert/Application2. Which path is this.Its written adjust to match your own directory path to your sysytem
I have created my development environment in C:\MyProjects\beerV1 and deployment environment as
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Beer-v1.



javac -classpath C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar -d<location of your class file> <src-file>
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have the same problem

Do we need the :classes:. after the servlet jar?
It doesn't seem to compile after if I use it.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

javac -classpath C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar -d<location of your class file> <src-file>



If you are on windows then please put claspath in double quotes

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar" -d<location of your class file> <src-file>
 
Ken Teoh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried it without the quotes and it works. However, can some one explain what is the command ":classes:." after the servlet-api.jar is used for? I took it out and it works
 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
Now I am able to compile as I followed all your instructions.
But now the problem is its not taking servlet-api.jar.
 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On Compilation its showing error like this
Cant resolve symbol class Httpservlet,HttpservletRequest,ServletException......


FYI................

C:\MyProjects\beerV1>javac -classpath :\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.0\common\lib\servlet-api.jar:classes: -d classes src\com\example\web\Beer
Select.java
src\com\example\web\BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src\com\example\web\BeerSelect.java:4: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src\com\example\web\BeerSelect.java:7: cannot resolve symbol
symbol : class HttpServlet
location: class com.example.web.BeerSelect
public class BeerSelect extends HttpServlet{
^
src\com\example\web\BeerSelect.java:9: cannot resolve symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest req,HttpServletResponse res)throws Servlet
Exception, IOException{
^
src\com\example\web\BeerSelect.java:9: cannot resolve symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest req,HttpServletResponse res)throws Servlet
Exception, IOException{
^
src\com\example\web\BeerSelect.java:9: cannot resolve symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest req,HttpServletResponse res)throws Servlet
Exception, IOException{
^
6 errors
 
Ken Teoh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the same problem initially
check the path of your servlet-api.jar
if you're desperate place the jar file in the same directory as your java source file and it should compile
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should use ; instead of : in Windows system.

Please try the command below.

 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends i tried all your sugestions. But its still showing same error.
1. Cai DongShan I changed : to ; But it isnt working.

2.Ken Teoh I put the jar file in inside my source file and also inside lib of jdk. Then also not working.

But when I am giving set classpath in command prompt it is showing the servlet-api.jar.

What can be the problems???
I am not able to find out.Anyone faced the similar problems please help.
 
Cai DongShan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
satya,

There is not space in the command you post. You create a batch file to include the following lines and try to run the batch file again.

C:
cd \MyProjects\beerV1>
rem copy my command here
 
satya mahapatra
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
At last I got it.What I did is first I uninstall the previous tomcat and again install it and gave the classpath. Now it is working.

To check classpath is working or not we can type command
javap javax.servlet.Servlet

Thanks for all your inputs.
 
Would you like to try a free sample? Today we are featuring tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic