如何在Eclipse中将一个包含Jar文件的文件夹添加到我的类路径? [英] How do I add a folder full of Jar files to my classpath in Eclipse?
问题描述
我甚至想要递归递归多个文件夹,并抓住所有的jar文件。
I would even want it to go recursively multiple folders down and grab all the jar files.
推荐答案
你不能通过IDE真的做到这一点,但是你可以做的是在IDE之外做一个程序来手动修改.classpath文件并添加jar。
You can't really do that through the IDE, but what you can do is do it outside the IDE and write a program to manually modify the .classpath file and add the jars.
例如,您的eclipse项目的.classpath文件将看起来像这样:
For example, the .classpath file for your eclipse project is going to look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java/main"/>
<classpathentry kind="src" path="src/java/tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.5.0_17"/>
<classpathentry kind="lib" path="test_reflib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="test_reflib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="test_reflib/commons-fileupload-1.1.1.jar"/>
</classpath>
所以你可以做的是编写一个程序,扫描你传入的目录,并手动修改这个.classpath文件包含jars。
So what you could do is write a program which scans the directories you pass into it, and manually modifies this .classpath file to contain the jars.
个人而言,我从来没有去过这样做的麻烦,只是一般把所有需要的jar放在一个文件夹中,在项目中。或者,如果这是我需要的JBoss jar,我只包括我想要的。
Personally, I never go to the trouble of doing this and just typically put all the jars I need in one folder and include them in the project. Or, if it's something like JBoss jars I need, I just include the ones I want.
这篇关于如何在Eclipse中将一个包含Jar文件的文件夹添加到我的类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!