• Post Reply Bookmark Topic Watch Topic
  • New Topic

class not found  RSS feed

 
bharat bhasin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have just started with java and am using packages.
I made a class A in package B and saved it in A.java in dir B.

package B;
public class A
{
int a=1;
private int pra=2;
public int pua=3;
protected int proa=4;

public A ( )
{
System.out.println(" Class A Package B");
}

void show( )
{
System.out.println(" a ="+a+"pra"+pra+"pua"+pua+"proa"+proa);
}
}

after that I made another class A1 and saved it as A1.java in package B in the same dir.

package B;
public class A1 extends A
{
int d=10;
public A1( )
{
super ( );
System.out.println("Class A1 subclass of A Package B");

}
void show1( )
{
//System.out.println(" a ="+a+"pra"+pra+"pua"+pua+"proa"+proa);
System.out.println("d="+d);
}
}

class A2
{
int e=11;
A c=new A( );
A1 q=new A1( );
void show1( )
{
System.out.println(" a ="+c.a+"pra"+c.pra+"pua"+c.pua+"proa"+c.proa);
System.out.println("d="+q.d+"e="+e);
}
}

On compilation A.java compiles fine but A1.java got the following error :
cannot find symbol
symbol : class A
public class A1 extends A
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you compiling? From the command line, you should change to the directory above B, and then issue a command like "javac B/A1.java". Then all required classes should be found (and compiled if necessary).

Alternatively, you can change into directory B, and do a "javac *.java".
 
bharat bhasin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot it worked.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!