• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot find symbol -the subclass and supercalss are in the same directory

 
zhy guo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.all the files are in the folder" I:\my codes\food\"
2.soure files:
1)B.java
package food;

public abstract class B extends Abc{
abstract void exit();
}

2)Abc.java
package food;

public abstract class Abc{
abstract void doit();
abstract void test();
}

3.before compile class B,class Abc is compiled successfully。then when trying to compile class B ,error raise :
b.java:3: cannot find symbol
symbol: class Abc
public abstract class B extends Abc{
^

1 error
err.JPG
[Thumbnail for err.JPG]
compiler error-cannot find symbol
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try javac *.java
 
zhy guo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John Jai.
It work!
But why....
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to consider the package structure when you compile and run.

So alternative way (or the correct one) is to compile like below -



Where food directory is present under C:/test
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Jai wrote:You have to consider the package structure when you compile and run.

So alternative way (or the correct one) is to compile like below -



Where food directory is present under C:/test

Yes, this is preferred way when you compile particular file.

and john mean while we can do using *.java if you go to the root package/food . I am curious to know the behind the sense of *.java even here also compiler have to do linking right?
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The listing for "Compiling multiple source files" here just tells that the wildcard option compiles all source files in the specified directory. I just copied the two source files in a different directory (not the directory 'food' with package name) but still was able to successfully compile them using * option.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic