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

Package Problem, Please Help...

 
Marius BONG
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i write 2 two java application (in separate file)
one is called SubclassB.java and another one is SuperclassA.java
-----------------------------------------------

when i compile the SuperclassA.java, no problem. But when i compile SubclassB.java this errors come up:
C:\My Documents\Java\SubclassB.java:3: package packageA does not exist
import packageA.*;
^
C:\My Documents\Java\SubclassB.java:5: cannot resolve symbol
symbol : class SuperclassA
location: class packageB.SubclassB
public class SubclassB extends SuperclassA
^
C:\My Documents\Java\SubclassB.java:16: cannot resolve symbol
symbol : class SuperclassA
location: class packageB.AnyClassB
SuperclassA obj = new SuperclassA( );
^
C:\My Documents\Java\SubclassB.java:9: cannot resolve symbol
symbol : method superclassMethodA ()
location: class packageB.SubclassB
superclassMethodA();
^
C:\My Documents\Java\SubclassB.java:16: cannot resolve symbol
symbol : class SuperclassA
location: class packageB.AnyClassB
SuperclassA obj = new SuperclassA( );
^
5 errors
Tool completed with exit code 1
do i have to set my -classpath or what ? pls tell me...i'm new in java.
[ February 12, 2002: Message edited by: Cindy Glass ]
 
aymen esawey
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the packageA is in folder say "thecode"
and your making packageB in that folder,you got to import thecode.packageA.*;
ie. always go up one level if your in another package within abig package(folder)
hope i'm right
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that your directory
C:\My Documents\Java
is in the classpath.
Then, when you say that SuperclassA is in package packageA, you have to make sure that it IS. You are promising the compiler that there is a subdirectory under the classpath with the given package name.
So SuperclassA.class needs to reside in
C:\My Documents\Java\packageA\SuperclassA.class
- unless of course you have it jarred up, in which case the jar file that contains that subdirectory needs to be in the classpath directory.
 
Marius BONG
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok..i understand now..thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic