my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "class  or package not found with Tomcat?" Watch "class  or package not found with Tomcat?" New topic
Author

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 java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
//import coreservlets.tobeimported;
public class withImport extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
tobeimported tbi = new tobeimported();
out.println(tbi.show());
}
}


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 .

Raghav.
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.

Ajan

[This message has been edited by Ajan Balakrishnan (edited February 23, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
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