aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse/Ant: package javax.servlet does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse/Ant: package javax.servlet does not exist" Watch "Eclipse/Ant: package javax.servlet does not exist" New topic
Author

Eclipse/Ant: package javax.servlet does not exist

Shyam Hai
Ranch Hand

Joined: Feb 04, 2009
Posts: 68

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
Marshal

Joined: Mar 22, 2005
Posts: 42624
    
  65
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.


Ping & DNS - my free Android networking tools app
Shyam Hai
Ranch Hand

Joined: Feb 04, 2009
Posts: 68
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
Marshal

Joined: Mar 22, 2005
Posts: 42624
    
  65
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

Joined: Feb 04, 2009
Posts: 68
Shyam Hai
Ranch Hand

Joined: Feb 04, 2009
Posts: 68


Project Stucture
Shyam Hai
Ranch Hand

Joined: Feb 04, 2009
Posts: 68
Shyam Hai
Ranch Hand

Joined: Feb 04, 2009
Posts: 68
My Project Structure:


src main folder
config
etc
jsp
lib
logging
messageresource
scripts
tlds

ant.properties
antenv.properties
build.xml
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42624
    
  65
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

Joined: Feb 04, 2009
Posts: 68
<!-- =================================================================== -->
<!-- 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

Joined: Aug 13, 2008
Posts: 20
Hi,
Make sure that the app.classpath includes your lib folder in the project.

Thanks & Regards,
Goutham Kumar P.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42624
    
  65
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

Joined: Feb 04, 2009
Posts: 68



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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Eclipse/Ant: package javax.servlet does not exist