views:

58

answers:

2

Hello

Every time im trying to access a normal java class from servlet (from other project) it gives me classNotFound exception, any idea how to fix this problem thanks in advance

+4  A: 

You need to make sure that the class is available to the servlet container. How you do that will partly depend on exactly what servlet container you're using, but you could always put the jar file in WEB-INF/lib or the class file in WEB-INF/classes (under the right folder structure of course).

Hopefully your servlet container documentation will give more details - for example, the Tomcat 6.0 documentation includes this page which gives details about exactly where Tomcat looks for classes.

Jon Skeet
I add the jar file to WEB-INF/lib and everything works fine, thanks for helping
Mohammed_Q
A: 

You should also make sure that your class includes a package statement. I don't believe that Tomcat looks kindly on classes in the default no-package.

duffymo
Everything works good by adding the jar file to the WEB-INF/libanyway thanks for help
Mohammed_Q