将 Jar 文件添加到 IntellijIdea 类路径 [英] Adding Jar files to IntellijIdea classpath
问题描述
我创建了一个新的 Intellij 项目.但是我不能在我的项目中使用第三方 jars.我的目录结构中的 jars 如下:repository/commons-logging/commons-logging-1.0.4.jar
repository/commons-lang/commons-lang-2.1.jar
等
I have created a new Intellij project. But I can't use the third party jars in my project. I have the jars in a directory structure as follows:
repository/commons-logging/commons-logging-1.0.4.jar
repository/commons-lang/commons-lang-2.1.jar
etc.
我只想通过指向存储库目录来添加它们,但找不到任何添加它们的方法.但是当我使用那些 jar 中的类或 API 时,编辑器无法解析这些类.我已经从项目结构中尝试过,但无法配置它.
I want to add them just by pointing to the repository directory, but couldn't find any ways to add them. But when I am using classes or API from that jars, the editor can't resolve the classes. I have tried from Project Structure but can't configure it.
推荐答案
转到 File-> Project Structure-> Libraries 并单击绿色+"将包含 JAR 的目录文件夹添加到 CLASSPATH.该文件夹中的所有内容都将添加到 CLASSPATH.
Go to File-> Project Structure-> Libraries and click green "+" to add the directory folder that has the JARs to CLASSPATH. Everything in that folder will be added to CLASSPATH.
更新:
现在是 2018 年.最好使用像 Maven 这样的依赖项管理器并外部化您的依赖项.不要再将 JAR 文件添加到/lib 文件夹中的项目中.
It's 2018. It's a better idea to use a dependency manager like Maven and externalize your dependencies. Don't add JAR files to your project in a /lib folder anymore.
这篇关于将 Jar 文件添加到 IntellijIdea 类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!