Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Compiling servlets

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !
I'm Java student and english too...
I have a problem. I found errors when try compile servlet-api.jar from Tomcat. Below, follow my environment and line commands:

CLASSPATH :
.;C:\Sun\SDK\bin;C:\Sun\SDK\jdk\jre\bin;C:\Sun\SDK\jdk\bin

CATALINA_HOME :
c:\Tomcat

JAVA_HOME:
c:\Sun\SDK\JDK

PATH:
C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Arquivos de programas\Borland\Delphi7\Bin;C:\Arquivos de programas\Borland\Delphi7\Projects\Bpl\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Arquivos de programas\Microsoft SQL Server\80\Tools\BINN;%PATH%;%JAVA_HOME%\bin;%PATH%;\des\delphi7\bpl

source path:
C:\Des\Java\web\proj\beerV1>

command to compile:
javac - classpath \Tomcat\common\lib\servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

Well, the compiler found the errors. My mind said... the compiler not found the path with servlet-api.jar ( in other words, tomcat/common/lib ) because my source code java (BeerSelect.java) got
library errors ( not found javax.HttpServlet.*; javax.Servlet.*; )
example:

In my computer, the TomCat is in directory c:\Tomcat\.....

what's wrong ?

Thank´s

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add servlet-api.jar to the classpath.
 
Antonio Marcos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, thank´s for attention but, still dont work...
see the environment more time:


Classpath according to your answer:
.;C:\Sun\SDK\bin;C:\Sun\SDK\jdk\jre\bin;C:\Sun\SDK\jdk\bin;%CATALINA_HOME%\common\lib\servlet-api.jar;%CATALINA_HOME%\common\lib\jsp-api.jar;.;%CLASSPATH%

follow the others:
CATALINA_HOME = c:\tomcat
JAVA_HOME = c:\sun\sdk\jdk
PATH=
C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Arquivos de programas\Borland\Delphi7\Bin;C:\Arquivos de programas\Borland\Delphi7\Projects\Bpl\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Arquivos de programas\Microsoft SQL Server\80\Tools\BINN;%PATH%;%JAVA_HOME%\bin;%PATH%;\des\delphi7\bpl;%CLASSPATH%

and, finally, the errors:

C:\Des\Java\web\proj\beerV1>javac -classpath c:\tomcat\common\lib\servlet-api.ja
r:classes:. -d classes src\com\example\web\BeerSelect.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 find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
src\com\example\web\BeerSelect.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse respo
nse)
^
src\com\example\web\BeerSelect.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse respo
nse)
^
src\com\example\web\BeerSelect.java:9: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {
^
6 errors

C:\Des\Java\web\proj\beerV1>



 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As this is nothing that is Tomcat-specific, and has more to do with setting up than Tomcat, it's been moved to a more appropriate forum with a change of subject.
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compiling Servlets
 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic