Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!

J JAR

Greenhorn
+ Follow
since Jan 10, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J JAR

Nevermind. The problem was using colons in my classpath instead of semicolons.

Duh.

Thanks anyways.
Nevermind. The problem was using colons in my classpath instead of semicolons.

Duh.

Thanks anyways.
I have the same problem in this post:
http://www.coderanch.com/t/171071/java-Web-Component-SCWCD/certification/classpath-help-examples

I get a "package javax.servlet does not exist" error when I try to use -classpath to specify the servlet-api.jar file in the Tomcat\common\lib directory. And yes...I can get the servlet to compile by adding setting the CLASSPATH environment variable in Windows....but I should still be able to compile this by using the -classpath option, right? Does anyone know what I'm doing wrong? Here is my source:

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);
}
}

Here is the path to servlet-api.jar:
C:\Tomcat\common\lib

Here is what I'm entering with the first couple of errors that get generated:

C:\Data\Java\WebProjects\beerV1>javac -classpath C:\Tomcat\common\lib\servlet-api.jar: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{


I'm sure it's just something stupid that I can't see. Please help!!!

Thanks!
Julie
I have this same problem! And yes...I can get the servlet to compile by adding setting the CLASSPATH environment variable in Windows....but I should still be able to compile this by using the -classpath option, right? Does anyone know what I'm doing wrong? Here is my source:

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);
}
}

Here is the path to servlet-api.jar:
C:\Tomcat\common\lib

Here is what I'm entering with the first couple of errors that get generated:

C:\Data\Java\WebProjects\beerV1>javac -classpath C:\Tomcat\common\lib\servlet-api.jar: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{


I'm sure it's just something stupid that I can't see. Please help!!!

Thanks!
Julie