简体   繁体   English

有没有一种方法可以在Eclipse中将“ libs”文件夹添加到我的项目中

[英]Is there a way to add a 'libs' folder to my project in Eclipse

The only way I know for adding additional libraries in a Java project (in Eclipse) is by manually adding them to the project's build path. 我知道在Java项目中(在Eclipse中)添加其他库的唯一方法是将它们手动添加到项目的构建路径中。

Is there a way in which I just create a folder, and anything inside it (.jars, to be more precise) is added to the classpath? 有没有一种方法可以创建一个文件夹,并将其中的任何内容(更确切地说是.jars)添加到类路径中? Can I do something like that in eclipse? 我可以在日食中做类似的事情吗?

Create a new Classpath Variable ( Preferences)which points to your directory and add it to build path. 创建一个新的Classpath变量(Preferences),该变量指向您的目录并将其添加到构建路径。

Use this in your project ( build path - Add Variable) 在您的项目中使用它(构建路径-添加变量)

For Ex: If you want to have C:\\MyDev\\Libs in your build path 对于Ex:如果要在构建路径中包含C:\\ MyDev \\ Libs

Eclipse-Windows-Preferences-Java-BuildPath-Classpath Variables- New Create a new entry calls MyDevLibs pointing to C:\\MyDev\\Libs Eclipse-Windows-Preferences-Java-BuildPath-Classpath变量-新建创建一个新条目,调用指向C:\\ MyDev \\ Libs的MyDevLibs

In your project-build path- configure build path - Libraries (tab) - Add Variable 在项目构建路径中-配置构建路径-库(选项卡)-添加变量

This should do. 这应该做。

First thing i will suggest is started using maven it handles the dependency problem very well 我建议的第一件事是开始使用Maven,它可以很好地处理依赖关系问题

or 要么

create a lib folder Put all the JARs into a lib folder inside of your project. 创建一个lib文件夹将所有JAR放入项目内部的lib文件夹中。

Now you can select all JARs in that folder, right click -> Build Path -> Add To Build Path. 现在,您可以选择该文件夹中的所有JAR,右键单击->构建路径->添加到构建路径。

Or just you can define a "User Library" which contains all the JARs and add that single item to your project's build path. 或者只是您可以定义一个包含所有JAR的“用户库”,并将该单个项目添加到项目的构建路径中。

You have to care about the classpath but also about the build.properties. 您不仅要关心类路径,还要关心build.properties。 If it is not part of the build properties, the libraries will not be part of the generated *.jar file. 如果它不是构建属性的一部分,则这些库将不属于生成的* .jar文件。

Let assume that your plugin is named 'rts.core.libs' and the project includes a folder named 'native/dll' . 假设您的插件名为“ rts.core.libs” ,并且项目包含名为“ native / dll”的文件夹。

Your file .classpath will look like 您的文件.classpath看起来像

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
        <attributes>
            <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="rts.core.libs/native/dll"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

and your build.properties file looks like 和您的build.properties文件看起来像

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               native/

暂无
暂无

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

相关问题 还有其他方法可以说出Eclipse和项目我的配置文件位于该文件夹中吗? - Are there other way to say Eclipse and project that my configuration file reside in that folder? 如何在 Eclipse 中向我的 Java 项目添加资源文件夹 - How do I add a resources folder to my Java project in Eclipse 将JSP和Servlet库添加到Eclipse的正确方法是什么? - What's the proper way to add JSP & Servlet libs to Eclipse? Eclipse无法在文件夹中找到我的项目 - Eclipse can't find my project in folder 我的 eclipse maven 项目中没有 java 资源文件夹 - There is no java resources folder in my eclipse maven project 将jar添加到构建路径后,jar从Eclipse中的libs(source)文件夹中消失 - 是bug还是我做错了什么? - Jar disappearing from libs (source) folder in Eclipse after adding it to build path - is it bug or my doing something wrong? 有没有办法从项目 libs 文件夹中的另一个 aar 文件访问一个 aar 文件的方法 - Is there any way to access methods of one aar file from another aar file in project libs folder Netbeans将外部文件夹添加到项目中(例如Eclipse上的链接文件夹) - Netbeans add an external folder into a project (like Linked Folder on Eclipse) 我想使用 Maven 从我的 libs 项目文件夹中加载所有 JAR - I want to load all JARs from my libs project folder with Maven 如何从磁盘将新文件夹添加到Eclipse项目中? - How to add a new folder from the disk, into an Eclipse project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM