Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javax.* Packages not found in import statements

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,
I am working on a windows 98 machine and using Apache Jserv. Also I have downloaded jdk1.2.2 and jsdk2.0 and am using them.
My sample.java file is in the servlets directory of my Apache Jserv dir under C:\Program Files. I have set path=C:\jdk1.2.2 and classpath = C:\javaBut when compiling, I get the following errors
C:\Program Files\Apache Group\Apache JServ\servlets>javac sample.java
sample.java:5: Package javax.servlet not found in import.
import javax.servlet.*;
^
sample.java:6: Package javax.servlet.http not found in import.
import javax.servlet.http.*;
^
sample.java:9: Superclass HttpServlet of class sample not found.
public class sample extends HttpServlet{
^
3 errors
I don't know what to do. I tried running the IsItWorking.class file to check if the Apache server is running and it works just fine. However when I copied it to the same dir (under a different name) and recompiled using javac I got the same errors listed above.
Here's what my autoexec.bat file looks like
SET PATH=%PATH%;"C:\jdk1.2.2\bin"
SET CLASSPATH=%CLASSPATH%;"C:\java"
Please help! I am working on a deadline!
Thanks very much.
Anjali Shenoy
 
One solution is to find the [red]servlet.jar[/red] file in your system then add that to the classpath when you compile.

>javac sample.java -classpath c:\[wherever the servlet.jar file is]

Usually, this is in one of the lib or lib\ext folders in your appserver. On my machine servlet.jar is at:

C:\JavaWebServer2.0\lib\servlet.jar
and
C:\Program Files\Allaire\JRun\lib\ext\servlet.jar

So I type either:

>javac sample.java -classpath C:\JavaWebServer2.0\lib\servlet.jar
or
>javac sample.java -classpath C:\Program Files\Allaire\JRun\lib\ext\servlet.jar

There's probably some jserv specific details on this but I've never worked with jserv. Someone will probably come along that knows more about this issue in general and give a more informed answer. I would like to know myself. However, when I've had this problem, that was how I solved it.

[sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
Your class path should be
set classpath=C:\JDK1.2.2\lib - for java.*

Put the 'servlet.jar' in the same directory and append the follwoing to the classpath

;C:\JDK1.2.2\lib\servlet.jar [sig][/sig]
 
Your class path should be
set classpath=C:\JDK1.2.2\lib - for java.*

Put the 'servlet.jar' in the same directory and append the follwoing to the classpath

;C:\JDK1.2.2\lib\servlet.jar

Prem [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top