The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Please solve this error

Posted by Manish Sachdev on November 20, 2001 at 7:42 AM

> 1) What classpath i should set?

> both. set your classpath to pkg1 AND pkg2

>
> 2) Tell me the Package statements for both the classes

> for SUPERCLASS:
> package pkg1;

> public class SUPERCLASS {
> ...
> }

> for SUBCLASS:
> package pkg2;

> import pkg1;

> public class SUBCLASS extends SUPERCLASS {
> ...
> }

> *or*
> package pkg2;

> public class SUBCLASS extends pkg1.SUPERCLASS {
> ...
> }

>
> 3) Also tell me the commands to run subclass being in pkg2

> ???
> i don't understand what u mean..


The OS which i use is Windows NT

My Directory structure is as follows


root
-----pack1
-----pack2

i added the following in the classpath

d:\root\pack1;d:\root\pack2

i compiled superclass in pack1 (package 1 direcotory) w/o errors

But when i compile subclass or (derived class) i
get the following errors :-

derived.java:3: Package pack1 not found in import.
import pack1.*;
^
derived.java:5: Superclass root.superclass of class pack2.derived not found.
class derived extends root.superclass
^
2 errors


i compile this file being in directory pack2.

Source code for both the files r as follows :

SUPERCLASS
package pack1;

public class superclass
{
protected int i=10;

public superclass(){}

public void display()
{
System.out.println("Superclass Display called !!! ");
}
}

Source code for DERIVED class is as follows

package pack2;

import pack1.*;

class derived extends root.superclass
{

public derived(){}

public static void main(String args[])
{
derived obj = new derived();
obj.display();

}
}

ClassPath which i have set is as follows

.;C:\jdk1.2.2\bin;C:\jdk1.2.2\lib;D:\Blazix\blazix.jar;.;C:\jsdk1.1\lib;c:\jsdk1.1\src;d:\.;d:\root\pack1;d:\root\pack2





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us