Hi, I'm making an online book store with the MVC pattern. I've made several beans to load and control user info and those are located in a package folder in my 'classes' directory. For example, classes/com/beans/myBean.class. Now I'm making controller classes to accept requests and process them accordingly from the front end. These controller classes are in classes/com/controllers directory and need to access those beans. However when I try to import the classes like 'import com.beans.*;', I get an error saying the package and/or directory com/beans does not exist?? What am I doing wrong?
Is the 'classes' directory on your classpath? Are the source files for that package reachable via the classpath?
Joined: Jan 16, 2005
No it's not. I'm running Windows 98. I'm using Jakarta tomcat 4.0.1 and j2sdk1.4.0_02. Both tomcat and js2dk are installed on the C:/. I've added to my autoexec.bat file JAVA_HOME for my tomcat installation, and CATALINA_HOME for my j2sdk installation. As for my classpath, I have a added a library JAR file located within the j2sdk installation but that is it. Perhaps that's my problem?
my whole application is under the webapps directory within the jakarta-tomcat directory. Should I add the tomcat directoty to my classpath as well??
Originally posted by Jenn Person: ok so for instance... my application is called jTunes. I would add c:/jakarta-tomcat-4.0.1/webapps/jTunes/WEB-INF/classes ?? Secondly, is this something I would have to do for any application? Could I just add the jakarta-tomcat-4.0.1 directory instead without having to be so directory specific?
This isn't really specific to webapps or Tomcat. It's a basic Java issue. The java compiler finds your sources, compiled dependencies, and libraries by looking on the classpath. To compile your servlets you will need A.) The classpath to point to the directory where your packages are b.) The servlet libraries (either servlet.jar or servlet-api.jar, under the TOMCAT_HOME/common/lib dir, depending on your version of Tomcat)