在一个 tomcat JSP 应用程序中,我有这个目录布局:
webapps/
myProjectName/
index.jsp
WEB-INF/
classes/
mypackage/
class1.java
class2.java
我正在尝试编译引用class2.java 的class1.java。它以如下形式编码:
package mypackage;
public class class1 extends class2 {}
和 class2 看起来像这样:
package mypackage;
public class class2 {}
但是,我在 class1 上收到一个错误,说找不到 class2。首先我编译了class2,它编译得很好,但是当我尝试编译class1时它失败了,说找不到class2。我尝试通过将其添加到 /etc/enviornment 来将目录添加到我的类路径(ubuntu):
/usr/local/tomcat/webapps/myProjectName/WEB-INF/classes
但它仍然无法编译。
知道有什么问题吗?
确切的错误输出是这样的:
javac "Page.java" (in directory: /usr/local/tomcat/webapps/developers/WEB-INF/classes/library)
Page.java:20: cannot find symbol
symbol : class DynamicPage
location: class library.Page
DynamicPage dynamicClasses = {new registerPage()};
^
Page.java:20: illegal initializer for <none>
DynamicPage dynamicClasses = {new registerPage()};
^
Page.java:20: cannot find symbol
symbol : class registerPage
location: class library.Page
DynamicPage dynamicClasses = {new registerPage()};
^
Page.java:34: cannot find symbol
symbol : class DynamicPage
location: class library.Page
DynamicPage selected = null;
^
Page.java:35: cannot find symbol
symbol : class DynamicPage
location: class library.Page
for (DynamicPage dp: dynamicClasses) {
^
5 errors
Compilation failed.