Issue
When importing the javax.servlet package in the java file, this package is found by vsCode. However, when I compiled the file I get the error 'package javax.servlet does not exist'. I don't know how to solve this problem. I cleared workspace, but it doesn't work. Tomcat5.5,vsCode1.67.2,java1.5,jdk1.5
Solution
In case the source files reference third-party library (JAR
) files, use the -cp
option and specify the JAR
file. For example:
javac -cp lib\mysql-connector-java-8.0.27.jar -d classes src\TestDb.java
If there are multiple JAR
files, they must be separated by semicolon like this:
javac -cp lib\mysql-connector-java-8.0.27.jar;lib\log4j-1.2.17.jar -d classes src\TestDb.java
Answered By - JialeDu
Answer Checked By - David Marino (JavaFixing Volunteer)