Icecream app HomeServlet Error help

I tried to run the code below as it is given from the lesson (link below) in Command Prompt:

javac -cp lib/servlet-api.jar -d webapps/icecream-app/WEB-INF/classes webapps/icecream-app/WEB-INF/src/HomeServlet.java

However, it gave a number of errors. After modifying it, the actual code I am now trying to run is shown below:

javac --enable-preview -source 22 -cp lib/servlet-api.jar -d webapps/icecream-app/WEB-INF/classes webapps/icecream-app/WEB-INF/src/HomeServlet.java

Now the error I get is:

webapps\icecream-app\WEB-INF\src\HomeServlet.java:11: error: implicitly declared class does not have main method in the form of void main() or void main(String args)
public class HomeServlet extends HttpServlet {
Note: webapps\icecream-app\WEB-INF\src\HomeServlet.java uses preview features of Java SE 22.
Note: Recompile with -Xlint:preview for details.

The AI Learning Assistant says:

“The error indicates that the HomeServlet class does not have a main method, which is expected for a standalone Java application. However, since HomeServlet is a servlet, it doesn’t need a main method. Instead, it should be deployed on a servlet container like Apache Tomcat.”

So if I don’t need a main method as I am using Apache Tomcat, how can I fix this error?

The link to the lesson where this code is:

https://www.codecademy.com/courses/learn-advanced-java/articles/advanced-java-servlets-processing-requests-and-building-responses

Project location shown below:

apache-tomcat-10.1.28 > webapps > icecream-app > WEB-INF > src > HomeServlet.java