I'm trying to use a class I defined in a package in my Java Web Project, however I keep getting errors when I use the class I defined in the package. The error is saying that the class cannot be resolved to a type. I am importing the package that I made that contains the class that I want to use.
- 1For future questions, an exact copypaste of the error/exception message and stacktrace would be more then helpful. Also a snippet of how you're importing and using it would be helpful. Otherwise it's a bit of guessing to the real cause.BalusC– BalusC2011-09-28 18:58:04 +00:00Commented Sep 28, 2011 at 18:58
Add a comment |
1 Answer
The class needs to be located in webapp's /WEB-INF/classes in a folder structure which represents the declared package. So if you have for example
package com.example; public class Foo { // ... } then you should have a /WEB-INF/classes/com/example/Foo.class file. Please keep in mind that this is case sensitive as everything else in Java.
Another possible cause is when you're trying to use it in a <jsp:useBean> tag, that it should have a (implicit) default constructor which doesn't throw an exception upon construction.