简体   繁体   English

如何在 jdk-11 中添加外部库?

[英]How can I add external libraries in jdk-11?

I want to compile a java code that using servlet with javac command.我想编译一个使用带有 javac 命令的 servlet 的 java 代码。 So I need to add servlet-api.jar into jdk-11 to compile it.所以我需要在 jdk-11 中加入 servlet-api.jar 来编译它。

You don't want to add the servlet-api.jar into the jdk.您不想将 servlet-api.jar 添加到 jdk 中。 You want to add the .jar to your classpath.您想将 .jar 添加到类路径中。

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您需要指定 .jar 和包含main()方法的类的完整路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM