I am about to finish the book Head First Java, I am at the last chapter. There's an example of how servlets can be used to call methods on other classes, so I wrote the corresponding code provided in the book; the code for the servlet goes like this :
and code for the method that's being called goes like this :
I am using Tomcat 8, my directory where I am keeping my classes is like this :
In webapps folder the structure of the folder where my class lands is like this
webbapps > PhraseOMatic
PhraseOMatic has two folders src and WEB-INF,
WEB-INF folder has the classes folder where the both the classes should land.
WEB-INF folder also has the XML file.
now when i compile the PhraseOMatic.java file, it compiles without any error and the class lands into the classes folder.
when I compile the KathyServlet.java the compiler shows the following error :
Keith Lynn wrote:Note that you only include the servlet-api.jar file as your CLASSPATH. But you don't include the classes directory where PhraseOMatic.class is found
Yes, I did think of that so what I did was that I pasted PhraseOMatic.class in every directory obviously that didn't help but I thought it was worth trying. So how do I get around this problem? how do I include the classes directory in cmd command?
What I also did was I had both the .java files inside the classes directory and tried to compile from that directory but that didn't help either