My directory structure is:
ABC/src/com/example/model/a.javaABC/src/com/example/web/b.java
Code for a.java:
package com.example.model;
public class a {
// ...
}
Code for b.java:
package com.example.web;
import com.example.model.*;
public class b {
// ...
}
I have already set the CLASSPATH environment variable to Tomcat’s servlet-api.jar, so I don’t need to include it in the javac command.
Now a.java compiles fine but when I compile b.java it says “package com.example.model does not exist”.
How is this caused and how can I solve it? I am using Ubuntu 10.10.
Add the output directory (ABC/classes or similar) to the javac classpath so that javac can find the classes.
Edit:
Actually, the preferred way is to add the -sourcepath option, as pointed out by AlexR.
That way, the compiler will use the current source of your code instead of the class files from the last time you compiled.