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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with javac and http

Status
Not open for further replies.

dognobbler

Programmer
Jul 4, 2003
46
0
0
GB
I recently had to reformat my hard drive and I am trying to rebuild an application. I had the actuall webapps part of the application backed up but not the rest of tomcat.

So I have download tomcat and installed tomcat and copied across the webapp.

Now when I try to javac one of my servlets I get the following error:

package javax.servlet does not exist

I thought this package was automatically installed as part of tomcat.

Can anyone explain to me why I might be getting this error and what I need to do to get rid of it.

Many thanks.

Andy
 
You do not have the jar file containing the package javax.servlet & its sub-packages ...

You either get it in the J2EE API (in j2ee.jar), or also it comes with tomcat, usually named servlet.jar in tomcat 4 & below, or servlet-api.jar in tomcat 5. It can be found in : TOMCAT_HOME/common/lib.

--------------------------------------------------
Free Database Connection Pooling Software
 
OK I have checked and I do have a file called servlet.jar in directory TOMCAT_HOME/common/lib but I am still not able to javac.

Can you think of a reason why javac cannot seem to find this file when I run it.

Could this be something to do with setting the environment variables for tomcat and Java SDK. Here is what I set:

USER VARIABLES

CATALINA_HOME
C:\tomcat

JAVA_HOME
C:\j2sdk1.4.2_05

SYSTEM VARIABLES

Path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\j2sdk1.4.2_05\bin
 
When I said "You do not have the jar file containing the package javax.servlet & its sub-packages ...", I meant you do not have it in your CLASSPATH - this is why javac cannot find the packages.

before compilation type :

set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\common\lib

--------------------------------------------------
Free Database Connection Pooling Software
 
Hi Sedj, thanks for the help but I tried that and it didn't make any difference.
Andy

 
Did you try :

set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\common\lib\servlet-api.jar

or

set CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\common\lib\servlet.jar

?

You must nam jar files by name, not just directory (its not like the -I switch in gcc)

--------------------------------------------------
Free Database Connection Pooling Software
 
Thanks I did that and it worked. However now I get the following errors even though my MyBeans does exist in the webapp. Any ideas why it cannot import MyBeans?

C:\tomcat\webapps\ profilePost.java
profilePost.java:11: package MyBeans does not exist
import MyBeans.memberBean;
^
profilePost.java:12: package MyBeans does not exist
import MyBeans.dbBean;
^
profilePost.java:56: package MyBeans does not exist
MyBeans.memberBean validMember = (MyBeans.memberBean) session.getAttri
bute("validMemberID");
^
profilePost.java:56: package MyBeans does not exist
MyBeans.memberBean validMember = (MyBeans.memberBean) session.getAttri
bute("validMemberID");
^
profilePost.java:110: package MyBeans does not exist
MyBeans.dbBean db = new MyBeans.dbBean();
^
profilePost.java:110: package MyBeans does not exist
MyBeans.dbBean db = new MyBeans.dbBean();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top