This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes class  or package not found with Tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "class  or package not found with Tomcat?" Watch "class  or package not found with Tomcat?" New topic

class or package not found with Tomcat?

Tom Barns
Ranch Hand

Joined: Oct 27, 2000
Posts: 138
Hi all
I have the following two files,i put both in a directory "coreservlets" under classes directory.when i compile
i got errors saying that no class or package coreservlets found.
when i put both in classes directory ,everythings is ok.
thanks for your help.
//package coreservlet;
public class tobeimported
public String show()
return "show from tobeimported ";
//package coreservlets;
import javax.servlet.*;
import javax.servlet.http.*;
//import coreservlets.tobeimported;
public class withImport extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException {
PrintWriter out = res.getWriter();
tobeimported tbi = new tobeimported();

Thanks for your help.
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
what is your file's name ?
is it tobeimported or not may be this can be the reason for your error .

Ajan Balakrishnan
Ranch Hand

Joined: Jan 04, 2001
Posts: 71
Add your class file directory in your CLASSPATH. This will help your servlet locate the class no matter where you keep 'em.
One quick question, Are you keeping your servelts inside "coreservlets" package. If so FYI, you need to either prefix the package name during servlet's invocation or change your servlet's context path inside your server.xml file.


[This message has been edited by Ajan Balakrishnan (edited February 23, 2001).]
jQuery in Action, 2nd edition
subject: class or package not found with Tomcat?
Similar Threads
problem with jsp accessing a servlets static methods
why we put all classes that we need to access from jsp in directories under classes?
compiling with packages
Servlet not refreshing
class extending another class in same directory