How to compile a servlet for Tomcat in command line? error: package javax.servlet does not exist

前端 未结 4 1337
孤独总比滥情好
孤独总比滥情好 2021-01-03 09:37

I\'ve got this error message when I compiled a Java file :

error: package javax.servlet does not exist

I installed a big .SH file for Jave

4条回答
  •  死守一世寂寞
    2021-01-03 10:26

    A Windows User:

    I faced this problem myself and here is the solution that worked fine

    Just Add this path to your CLASSPATH environmental variable "C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar"

    The path before the jar name can differ based on your installation. Just go to your lib folder of tomcat and copy the whole directory.

    More info for beginners: You can find Environmental variables here MyComputer -> Properties ->Advanced Settings -> Advanced tab

    Now you can simply go to cmd prompt and type "javac Myclass.java"

    Hope this helps!

提交回复
热议问题