[英]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.