2013年7月23日星期二

With package name inherited error: cannot find symbol

I wrote three categories:
father.java
package m;
public class father {
public int x;
public int add (int a, int b) {
int sum = a + b;
return sum;
}
}

son.java
package n;
import m. *;
public class son extends father {

}

fcb.java
import m. *;
import n. *;

public class fcb {
public static void main (String agrs []) {
son son1 = new son ();
son1.x = 2;
System.out.println (son1.x);
System.out.println (son1.add (5,6));
}
}

fcb.java on the C: \ java
m and son.java folder on C: \ java \ n
father.java on the C: \ java \ n \ m
father.java bytecode in C: \ java \ n \ m

C: \ java \ n> javac son.java
son.java: 2: error: cannot find symbol
public ; class son extends father {; ^
symbol: class father
1 error


I ask why? I thought for a long time do not know why. Thank you.

------ Solution ------------------------------------ --------
environment variable is the reason?
------ For reference only -------------------------------------- -
added:
C: \ java \ n> echo% classpath%
C: \ Program Files \ Java \ jdk1.7.0_15 \ jre \ lib \ rt.jar;.;
------ For reference only ---------- -----------------------------
own solution. . .

没有评论:

发表评论