You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Stacy <cs...@crystaliz.com> on 2000/04/13 22:57:41 UTC

beginner question (really) about how JAVA finds classes when compiling

>>>>> On Thu, 13 Apr 2000 14:36:58 -0400, Christopher Stacy ("C") writes:

 C> I am running Tomcat (a few weeks old) (with Apache) on NT.
 C> I am using the default "web.xml" file.
 C> I have a JSP (located in "webapps/mytop/my.jsp") that invokes a bean FOO.Bean.
 C> The bean is being loaded from "webapps/mytop/WEB-INF/classes/FOO/Bean.class".

 C> Now I want the bean to instantiate another class Foo, which is part of the same FOO package.
 C> The source file "Foo.java" (like "Bean.java") begins with a "package FOO" statement.
 C> I placed "Foo.java" in the same directory (FOO) and compiled it.

 C> However, the following statement in Bean.java will not compile:
 C> 	 Foo f = new Foo();
 C> because it cannot resolve the symbol "Foo".

 C> How do I tell JAVA how to resolve this symbol and make this work?

 C> Both classes are in the same package, so I don't think I need to import anything.
 C> It must be a confusion about where the class files live, or else something even more basic.

My problem description above could have been a little confusing
(because it's so simple).  The question is really: I am sitting in
a directory named FOO trying to javac a file Bean.java which makes
reference to the class "Foo".  There is a "Foo.java" and "Foo.class"
file sitting in this same directory already.  CLASSPATH includes ".".
Both classes are in the same package FOO.  What else do I need to do?

The problem is presumably unrelated to Tomcat.
(Of course, I still don't realize what the problem is.)


Re: beginner question (really) about how JAVA finds classes when compiling

Posted by Mike LaBudde <mi...@hksystems.com>.
Go up one directory level (i.e. the parent to FOO) and issue the command:

javac.exe -d . FOO.Foo.java

HTH,

Mike


At 4/13/2000 04:57 PM -0400, you wrote:
> >>>>> On Thu, 13 Apr 2000 14:36:58 -0400, Christopher Stacy ("C") writes:
>
>  C> I am running Tomcat (a few weeks old) (with Apache) on NT.
>  C> I am using the default "web.xml" file.
>  C> I have a JSP (located in "webapps/mytop/my.jsp") that invokes a bean 
> FOO.Bean.
>  C> The bean is being loaded from 
> "webapps/mytop/WEB-INF/classes/FOO/Bean.class".
>
>  C> Now I want the bean to instantiate another class Foo, which is part 
> of the same FOO package.
>  C> The source file "Foo.java" (like "Bean.java") begins with a "package 
> FOO" statement.
>  C> I placed "Foo.java" in the same directory (FOO) and compiled it.
>
>  C> However, the following statement in Bean.java will not compile:
>  C>     Foo f = new Foo();
>  C> because it cannot resolve the symbol "Foo".
>
>  C> How do I tell JAVA how to resolve this symbol and make this work?
>
>  C> Both classes are in the same package, so I don't think I need to 
> import anything.
>  C> It must be a confusion about where the class files live, or else 
> something even more basic.
>
>My problem description above could have been a little confusing
>(because it's so simple).  The question is really: I am sitting in
>a directory named FOO trying to javac a file Bean.java which makes
>reference to the class "Foo".  There is a "Foo.java" and "Foo.class"
>file sitting in this same directory already.  CLASSPATH includes ".".
>Both classes are in the same package FOO.  What else do I need to do?
>
>The problem is presumably unrelated to Tomcat.
>(Of course, I still don't realize what the problem is.)
>
>
>--------------------------------------------------------------------------
>To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commmands, email: tomcat-user-help@jakarta.apache.org