java 导入外部 jar 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4421730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:17:32  来源:igfitidea点击:

importing external jar files

javacommand-lineclasspathjavac

提问by Pavithra Gunasekara

I have written a Java code which imports an external jar file. How can I compile and run it on the command-line?

我编写了一个导入外部 jar 文件的 Java 代码。如何在命令行上编译和运行它?

Thanks in advance!

提前致谢!

回答by khachik

Compiling from the command-line:

从命令行编译:

javac -cp path_to_jar1.jar:path_to_jar2.jar Example.java

Running:

跑步:

java -cp .:path_to_jar1.jar:path_to_jar2.jar Example

For Windows, use ;as a path-separator (instead of :).

对于 Windows,;用作路径分隔符(而不是:)。