Search code examples
javaservletsjava-11openjdk-11

How can I add external libraries in jdk-11?


I want to compile a java code that using servlet with javac command. So I need to add servlet-api.jar into jdk-11 to compile it.


Solution

  • You don't want to add the servlet-api.jar into the jdk. You want to add the .jar to your classpath.

    You can try something like:

    javac -cp servlet-api.jar MainClass
    

    You need to specify the full path to you .jar and to your class which contains the main() method