Hi,
My java program locations are as follows:
BeerSelect\src\com\example\model\BeerExpert.java
and BeerSelect\src\com\example\web\BeerSelect.java
My compilation command for the first program is:
javac -d classes src/com/example/model/BeerExpert.java
This compiles fine and creates a class file in the appropriate subdirectory under classes (classes/com/example/model)
But I get the following error when trying to compile the BeerSelect.java file.
C:\projects\BeerSelect>javac -d classes src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.BeerExpert;
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
I think I'm making a very silly mistake here. But cannot figure out what.
Using Java version 1.5.0_06. The source code is as follows (from the book)
package com.example.model;
import java.util.*;
public class BeerExpert{
public ArrayList<String> getBrands(String color){
ArrayList<String> brands = new ArrayList<String>();
if (color.equals("amber")){
brands.add("Jack Amber");
brands.add("Red Moose");
}
else {
brands.add("JAil PAle Ale");
brands.add("Gout Stout");
}
return (brands);
}
}
package com.example.web;
import com.example.model.BeerExpert;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);
}
}
Any help is greatly appreciated.
-Jane
My java program locations are as follows:
BeerSelect\src\com\example\model\BeerExpert.java
and BeerSelect\src\com\example\web\BeerSelect.java
My compilation command for the first program is:
javac -d classes src/com/example/model/BeerExpert.java
This compiles fine and creates a class file in the appropriate subdirectory under classes (classes/com/example/model)
But I get the following error when trying to compile the BeerSelect.java file.
C:\projects\BeerSelect>javac -d classes src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.BeerExpert;
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
I think I'm making a very silly mistake here. But cannot figure out what.
Using Java version 1.5.0_06. The source code is as follows (from the book)
package com.example.model;
import java.util.*;
public class BeerExpert{
public ArrayList<String> getBrands(String color){
ArrayList<String> brands = new ArrayList<String>();
if (color.equals("amber")){
brands.add("Jack Amber");
brands.add("Red Moose");
}
else {
brands.add("JAil PAle Ale");
brands.add("Gout Stout");
}
return (brands);
}
}
package com.example.web;
import com.example.model.BeerExpert;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
request.setAttribute("styles", result);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);
}
}
Any help is greatly appreciated.
-Jane