Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding package usage

 
Shaan patil
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

I have five java files like this

1. Three files(A.java,B.java,C.java) which are of same package p1(These are in folder c:\p1)

2. Two files(D.java,E.java) of package p2 type(These are in folder c:\p2 )

The class in D.java extends p1 package class A class in A.java file(as p1.A)

But I am unable to run the code as it gives a compile error ?
Compile error :It is saying canot find A class package

CLASSPATH is set as to point to c:\


What is the issue ?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shaan patil:
...The class in D.java extends p1 package class A class in A.java file(as p1.A)...

Are you sure you're extending D "as p1.A" (that is, class D extends p1.A)? Or are you just extending A (that is, class D extends A)?

If you are not providing the qualified name (p1.A) and you don't have an import statement (import p1.*; or import p1.A;), then you will get the error "cannot find symbol" for class A.
[ January 04, 2008: Message edited by: marc weber ]
 
Shaan patil
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Ya I am sure I have extended the full qualified name and used import statements also .

But still the issue reamins ?

Regards
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works for me.

c:\p1\A.java...

c:\p2\D.java...

Command prompt...
>javac -cp c:\ c:\p2\D.java

How are you specifying your classpath? Is it in the command line? Or have you set a system variable? If you set a system variable, try it in the command line (as I did above), and this will tell you if something is wrong with your system variable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic