简体   繁体   English

在运行时访问jar文件库

[英]Accessing jar file libraries at runtime

In my code, near the top of one of the source files is this line: 在我的代码中,以下源文件之一的顶部附近是这一行:

import com.google.code.chatterboxapi.ChatterBox;

This is an external jar library, and when I ran my code, which I build into a Jar file, in the command line outside the IDE I was using, Java complained that it couldn't find com.google.code.chatterboxapi.ChatterBox. 这是一个外部jar库,当我运行代码并将其构建到Jar文件中时,在我使用的IDE外部的命令行中,Java抱怨说找不到com.google.code.chatterboxapi.ChatterBox 。 How do I tell the JVM where to find the jar where the libraries are? 我如何告诉JVM在哪里找到这些库所在的jar?

You use the classpath option of java 您使用Java的classpath选项

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A : separated list of directories, JAR archives,
              and ZIP archives to search for class files.

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

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