ARTICLE AD BOX
Although I have taken the following steps, I am still encountering the error "jakarta.servlet does not exist." VS Code shows this error with red squiggly lines, and on hover it displays the message: "The import jakarta cannot be resolved."
I have referenced servlet-api.jar.
I executed the command with the paths /opt/tomcat/lib/* and /opt/tomcat/lib/servlet-api.jar.
Environment in which I am practicing:
VS Code
Java (version 21)
Tomcat (version 11)
No IDE
The same error was resolved by referencing servlet-api.jar when I was using tomcat - version 10.
2
1.verify which jar contains the jakarta.servlet
ls /opt/tomcat/lib
may be it doesn't exist or it may be the old javax servlet jar then the vscode will keep showing the package jakarta.servlet does not exist
2.add the correct jar to the classpath if you are not using build tools like maven or gradle
3.In some newer distributions,file name might be slightly different .confirm the exact name in /opt/tomcat/lib then select the clean java language server workspace -> restart and delete
Explore related questions
See similar questions with these tags.
