Note that you could also do this from the command prompt as follows...
D:\LearnJava\Two>javac -cp ../.. Child.java
In this case, your current directory is D:\LearnJava\Two, and you are specifying a classpath (-cp) that is two directories higher (../..), which puts you back at D.
OR you could simply use D as your current directory (which is where these packages reside, so the dot in your classpath should work), and then provide the relative path for compiling Child.java...
D:\>javac LearnJava/Two/Child.java
Kok Lum Chan
Greenhorn
Joined: Apr 12, 2009
Posts: 10
posted
0
Hi Marc,
Thank you for your guidance and your recommentation works.
marc weber wrote:
koklum chan wrote:...I have updated that CLASSPATH to point to the location of the Parent.class but i still unable to figure out why i got the error.
Classpath = .;D:\LearnJava;D:\LearnJava\Two;D:\LearnJava\One;<some other paths>...
Java is looking for the package, "LearnJava.One." The location of this is simply "D:\", which does not appear to be included in your classpath.
This is what i do not understand. Why Java cannot locate the parent.class when i am using absolute path (D:\LearnJava\One) in CLASSPATH but specifying D:\ works ?
Is it trying to locate the package (not covered in my classpath) then only the class in the package (covered in the classpath) ?
This is what i do not understand. Why Java cannot locate the parent.class when i am using absolute path (D:\LearnJava\One) in CLASSPATH but specifying D:\ works ?
Is it trying to locate the package (not covered in my classpath) then only the class in the package (covered in the classpath) ?
The classpath is used to specify the location of the root of the class files -- not the location of the class files. So if you specify the class path as D:\LearnJava\One and you specify the package as LearnJava.One, then it will look for the class file in D:\LearnJava\One\LearnJava\One\Parent.class.