Thanks Will, I think I understand what you are saying.........
I will always use packages and it won't bite me again. Thanks R -----Original Message----- From: Will Hartung [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 6:50 PM To: Tomcat Users List Subject: Re: Beans in packages vs beans not in packages Actually, it's quite simple. You see, your Java source files only have "package" scope for classes that are not imported. This means, that your source can only refer to classes within the same package directly. All others must have a fully qualified package name (e.g. java.util.Collection) or be imported. The 'import' statement requires a fully qualified class name, and the class name includes its package. Classes that have no 'package' statement are in an Unnamed package. Typically this Unnamed package is the "Current Directory", which is a logical name, not "usr.will.javacode.projects.test". But, since the classes are unnamed, you can't get a fully qualified name for them in your source code. Packages are a wonderful thing, but their relationship with path names and directories (which is an implementation detail) causes SO much confusion for people. You can 'import' your classes from the same package, even though its unnamed, and even though you don't need to, it's "legal". If you have X.java and Y.java in the same directory, where Y imports X, and with both files lacking a 'package' statement, the 'import' will work. It's just unnecessary. This is why the imports will fail for your classes, even though they're on the CLASSPATH. You can't properly name them. Q.E.D, that's why your classes need to be in a package. Best Regards, Will Hartung ([EMAIL PROTECTED]) ----- Original Message ----- From: "Ron Day" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Wednesday, July 10, 2002 3:28 PM Subject: RE: Beans in packages vs beans not in packages > but why does the package version work without the "import" > > R > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 10, 2002 5:19 PM > To: Tomcat Users List > Subject: Re: Beans in packages vs beans not in packages > > > > you need to import it using the import statement. > <% import <classname> %> > > RS > > > > > "Ron Day" <[EMAIL PROTECTED]> on 07/10/2002 05:20:27 PM > > Please respond to "Tomcat Users List" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > cc: > > Subject: Beans in packages vs beans not in packages > > Hi, > > When I run a webapp with a bean in a package -- say "com.form", everything > works fine. But when I try to run a bean that is not in a package I always > get class not found error. > > 1)I am using usebean in both cases, one has class name, one has full > package > name. > 2)Bean has package name in one but no in the other. > 3)Bean is in class directory at top level for no package, and in correct > package directory structure for package. > > There are no other changes, except to recompile bean, and restart tomcat. > > Any help appreciated. > > ron > > > > > -- > To unsubscribe, e-mail: < > mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: < > mailto:[EMAIL PROTECTED]> > > > > > > > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
