Im trying to compile the second version of the servlet that calls the method in the model class. But the compiler says that the model class's package doesnt exist though i have imported the package properly. Servlet code and the model class code is given below:
SERVLET CLASS : BeerSelect.java path : src/com/example/web/BeerSelect.java
MODEL CLASS: BeerExpert.java path : src/com/example/model/BeerExpert.java
Nabila Mohammad wrote:Importing the class is not enough. Make sure your classpath is set right.
Thanks for your replies. It worked !! and im able to compile the class now . But, could anybody explain why we need to tell the compiler the path of the model class eventhough we have imported the class in the source code?
From the way i think,
Importing the class means you are going to use the imported class in your current file...
But the compiler does not know where to look for the class you have imported.
So in that case ,you have to set the classpath so it can find the location of the file you have imported.
Hope this helps.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!