• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse/Ant: package javax.servlet does not exist

 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Now i using java 1.4.2 jsdk

Before i am using java1.5

But i want to run java1.4 the same project

But i get this error how can i rectify.Please...........


[javac] D:\Projects\DizleeB\src\com\dizleeB\action\BaseServlet.java:6: package javax.servlet does not exist
[javac] import javax.servlet.RequestDispatcher;
[javac] ^
[javac] D:\Projects\DizleeB\src\com\dizleeB\action\BaseServlet.java:7: package javax.servlet does not exist
[javac] import javax.servlet.ServletException;
[javac] ^
[javac] D:\Projects\DizleeB\src\com\dizleeB\action\BaseServlet.java:8: package javax.servlet.http does not exist
[javac] import javax.servlet.http.HttpServletRequest;
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you adding the servlet jar file to the classpath during compilation? The servlet classes are part of JEE, not JSE, so in this regard it makes no difference whether you're using Java 1.4 or Java 5.
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before i did not add servlet jar.when i useing java 1.5.

But now i add servlet jar also in lib folder.
in same project with j2sdk1.4.2

Now i get package javax.servlet does not exist this error.
Please help me.....
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you compiling? No directories (called "lib" or otherwise) are added automatically to the classpath during compilation when using "javac".
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Project Stucture
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Project Structure:


src main folder
config
etc
jsp
lib
logging
messageresource
scripts
tlds

ant.properties
antenv.properties
build.xml
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The directory structure doesn't matter if the jar file is not added to the classpath.
I'll ask again: How are you compiling the class? Post the complete command you're typing in, along with the directory in which you're executing it.

By the way, you can't use the [img] tag to link to files that are on your local desktop. You need to upload them to a public server, or use the "Attachments" option during posting.
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<!-- =================================================================== -->
<!-- Compile App -->
<!-- =================================================================== -->
<target name="compile" depends="props, prepare">
<echo message="Compiling source files......................"/>
<echo> classpath = ${app.classpath}</echo>
<tstamp/>
<javac srcdir="${src.dir}" destdir="${staging.home}"
includes="**/*.java"
classpath="${app.classpath}"
debug="on" optimize="off" deprecation="on" />
</target>
<target name="resourceinclude" depends="compile">
<copy todir="${staging.home}/com/dizleeB" >
<fileset dir="${src.dir}/" includes="messageresource/*.properties"/>
</copy>

</target>

Above that is java compling..coding
I was complied the files thru build.xml
I am using Eclipse.
I add all jar files thru java build path
 
Goutham Pallipati
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Make sure that the app.classpath includes your lib folder in the project.

Thanks & Regards,
Goutham Kumar P.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that the app.classpath includes your lib folder in the project.

Putting directories in the classpath doesn't do any good if the classes are in jar files; the actual jar files need to be in the classpath.
 
Shyam Hai
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Yes.That is a problem.
Before i did not give class path for servlet jar file.
i give that correctly.
now its working fine.

THANK YOU VERY MUCH for your guidance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic