Two Laptop Bag*
The moose likes Java in General and the fly likes About Package and Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "About Package and Classpath" Watch "About Package and Classpath" New topic
Author

About Package and Classpath

Prashant Neginahal
Ranch Hand

Joined: Dec 04, 2002
Posts: 76
Hi Everbody,
I have some problem with package and class path.It goes like this ,
I have two .java files in d:\java\ folder.
First file is Complex.java.
-----------------------------------------
package com.prashant.Hello;
public class Complex
{
public Complex()
{
System.out.println("From com.prashant.Complex class");
}
}
--------------------------------------------
Second file is Simple.java.
--------------------------------------------
package com.prashant.Hello;
public class Simple
{
public Simple()
{
System.out.println("From com.prashant.Simple class");
}
}
--------------------------------------------
Ok , these two files i am using in another source file located in e:\java\ folder as below,
import com.prashant.Hello.*;
class Testing
{
public static void main(String a[])
{
Complex objComplex=new Complex();
Simple objSimple=new Simple();

}
}
Before that i set class path as CLASSPATH=.;d:\java;
But once i compile Testing.java, it is giving error as
Testing.java:6: cannot resolve symbol
symbol : constructor Complex ()
location: class Complex
Complex objComplex=new Complex();
^
Testing.java:7: cannot resolve symbol
symbol : constructor Simple ()
location: class Simple
Simple objSimple=new Simple();
^
2 errors

It works perfectily if i place Testing.java in some pavkage.
Hope somebody will help me.
Thanks
Prashant


--------------<br />Prashant<br />SCJP-91%
Nayanjyoti Talukdar
Ranch Hand

Joined: Feb 12, 2002
Posts: 71
Hi,
If u have those 2 files under folder called folder..then u have to set the classpath for d:\java\folder. Under that, u should have the required package structure.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: About Package and Classpath