Hello ,
I am facing problem in
java packages
The directory structure is => work\pack1\pack2
The directory structure of packages are => \pack1\pack2
package pack2;
public class C
{
public C()
{
System.out.println("Inside C");
}
}
__________________________________________________________________________
As pack2 is in pack1 , i am trying to instantiate an object of class C , from pack1 , after compiling C.java
__________________________________________________________________________
package pack1;
import pack2.*;
public class B
{
public B()
{
System.out.println("Inside B");
}
public static void main(
String arg[])
{
B b = new B();
C c = new C();
}
}
___________________________________________________________________________
There is no error in compilation of class B , but when i run the class B from one step up directory(from work ) like this
java pack1.B
it gives a runtime exeception
[ Exception in
thread "main" java.lang.NoClassDefFoundError: pack2/C ]
___________________________________________________________________________
Please tell why is it happening and please give the solution . I am working on a Linux (Red hat) machine .
If it's a problem of setting CLASSPATH , please tell me how to set CLASSPATH
Regards
[ February 04, 2006: Message edited by: faisal usmani ]