File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes package problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package problem" Watch "package problem" New topic

package problem

Nancy Lee

Joined: Mar 23, 2002
Posts: 15
Hi there:
I have downloaded two files with the same package-name as their first statement from internet.
Their file structures are as follow:
1. for :
package lvevl1.level2.level3;
some import statements;
public class A { some statements; }
2. for
package level1.level2.level3;
some import statements;
public class B extends A { some statements;}
I created a directory path :
c:\level1\level2\level3\ in my Window 98 driver c
then stored the two downloaded files there.
It is OK to compile and create A.class. But when I tried to compile, I got an error message : SuperClass Level1.Level2.Level3.A of class Level1.Level2.Level3.B not found.
This is my first time using package. Can anyone tell me what's wrong? Thanks.
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
When you compile the class B you need to specify where class A is located in the classpath. For instance, if you are in c:\level1\level2\level3 you compile class A
> javac
And then to compile class B you need to enter the following:
> javac -classpath ..\..\..;%CLASSPATH%
And everything should be fine.
The "..\..\.." refers to C:. So in B there should be an import statement for A like
import level1.level2.level3.A;
To find A, the compiler must have a clue where to find level1 first (which is C: )
[ March 29, 2002: Message edited by: Valentin Crettaz ]

[Blog] [Blogroll] [My Reviews] My Linked In
Nancy Lee

Joined: Mar 23, 2002
Posts: 15
Thanks. It works now.
I agree. Here's the link:
subject: package problem
It's not a secret anymore!