Am having directory structure like this and files: beerV1\src\com\example\web\BeerSelect.java
beerV1\src\com\example\model\BeerExpert.java
beerv1\classes
BeerExpert.java package com.example.model;
import java.util.*;
public class BeerExpert {
public
String getBrands() {
String suc="sucess";
return suc ;
}
}
BeerSelect.java package com.example.web;
import com.example.model.*;//IMPORTING
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 {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
BeerExpert Beertype = new BeerExpert();
String brands=Beertype.getBrands();
out.print(brands);
}
}
Oncompilng: c:\Allfiles\Programs\java\MyProjects\beerV1>javac -classpath C:\apache-tomcat-5.5.25\common\lib\servlet-api.jar -d classes src\com\example\model\BeerExpert.java
c:\Allfiles\Programs\java\MyProjects\beerV1>
And i get expected directory structure created:
beerV1\classes\com\example\model\BeerExpert.class
oncompiling c:\Allfiles\Programs\java\MyProjects\beerV1>javac -classpath C:\apache-tomcat-5.5.25\common\lib\servlet-api.jar -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.*;
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert Beertype = new BeerExpert();
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert Beertype = new BeerExpert();
^
3 errors
Am not able to find where am wrong but the package was present .