我在编译BeerSelect.java
提示如下错误:
E:\wsj\JavaWeb\BeerSelect>javac -d classes src\com\example\web\BeerSelect.java
src\com\example\web\BeerSelect.java:3: 错误: 程序包com.example.model不存在
import com.example.model.BeerExpert;
^
src\com\example\web\BeerSelect.java:20: 错误: 找不到符号
BeerExpert beerExpert = new BeerExpert();
^
符号: 类 BeerExpert
位置: 类 BeerSelect
src\com\example\web\BeerSelect.java:20: 错误: 找不到符号
BeerExpert beerExpert = new BeerExpert();
^
符号: 类 BeerExpert
位置: 类 BeerSelect
3 个错误
E:\wsj\JavaWeb\BeerSelect>
E:\wsj\JavaWeb\BeerSelect>
我检查BeerSelect.java
导入的路径:import com.example.model.BeerExpert
;但编译不过,不清楚哪里不对,求教大家能不能帮我看看? 本人刚在学习servlet相关的。
---------------------------------------以下相关信息--------------------------------------
目录结构如下:
BeerExpert.java
的代码
package com.example.model;
import java.util.ArrayList;
import java.util.List;
public class BeerExpert {
public List getBrands(String color){
List brands = new ArrayList();
return (brands);
}
}
BeerSelect.java
的代码
package com.example.web;
import com.example.model.BeerExpert;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.List;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c = request.getParameter("color");
out.println("<br>Got beer color " + c);
BeerExpert beerExpert = new BeerExpert();
List result = beerExpert.getBrands(c);
}
}
系统环境变量: