The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001



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.


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

> package pkg1;

> public class SUPERCLASS {
> ...
> }

> 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


i added the following in the classpath


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

But when i compile subclass or (derived class) i
get the following errors :- Package pack1 not found in import.
import pack1.*;
^ 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 :

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();


ClassPath which i have set is as follows



Sponsored Links

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