It's not a secret anymore!
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
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).]
I agree. Here's the link:
subject: class or package not found with Tomcat?
jQuery in Action, 3rd edition