This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "About Package and Classpath" Watch "About Package and Classpath" New topic

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
package com.prashant.Hello;
public class Complex
public Complex()
System.out.println("From com.prashant.Complex class");
Second file is
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, it is giving error as cannot resolve symbol
symbol : constructor Complex ()
location: class Complex
Complex objComplex=new Complex();
^ cannot resolve symbol
symbol : constructor Simple ()
location: class Simple
Simple objSimple=new Simple();
2 errors

It works perfectily if i place in some pavkage.
Hope somebody will help me.

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

Joined: Feb 12, 2002
Posts: 71
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.
I agree. Here's the link:
subject: About Package and Classpath
Similar Threads
Command line arguments
Help with compiling packages
another compiling error
compiling in unix
problem using javac with -classpath option