aspose file tools*
The moose likes Beginning Java 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 » Beginning Java
Bookmark "Compiling servlets" Watch "Compiling servlets" New topic
Author

Compiling servlets

Antonio Marcos
Greenhorn

Joined: May 31, 2009
Posts: 3
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


Antonio Marcos Fernandes
System Analyst - Brazil
I believe at the force inside me...


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60056
    
  65

You need to add servlet-api.jar to the classpath.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Antonio Marcos
Greenhorn

Joined: May 31, 2009
Posts: 3
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60056
    
  65

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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Compiling Servlets


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiling servlets
 
Similar Threads
when i try run: weka.jar i get these error: "Error: Could not find Java 2 Runtime "
Problem in building the application
servlet basics
Problem to compile servlet and Tomcat
Ant: InstallTask (etc.) cannot be found