Eclipse buildpath automatically taking all JARs of a internal directory

后端 未结 10 1754
醉梦人生
醉梦人生 2020-12-15 05:34

How do I configure my project buildpath to have a set of .jar files located in the same directory automatically included in the buildpath ? Meaning that adding a new .jar fi

相关标签:
10条回答
  • 2020-12-15 06:20

    I built a tool which generates the .classpath (and .project), but it requires you to specify the list of jars in your ant build. It could probably be extended to read a list of jar files.

    http://sweetened.googlecode.com/

    0 讨论(0)
  • 2020-12-15 06:21

    On a windows machine you could do what uzhin said with a one liner on the command line.

    Supposing you had set up a variable in Eclipse called AXIS2_HOME that points to c:\javalibs\axis2-1.4.1, this example uses the "for" command to iterate all of the .jar files in the c:\javalibs\axis\lib directory and writes the .classpath nodes a file called addto.classpath. (Note: The carat character ^ escapes the < and > on the command line so they don't do what they usually do.)

    for %i in (c:\javalibs\axis2-1.4.1\lib\*.jar) do @echo     ^<classpathentry kind="var" path="AXIS2_HOME/lib/%~ni%~xi"/^>  >> addto.classpath
    

    You end up with something like this in the file...

    <classpathentry kind="var" path="AXIS2_HOME/lib/activation-1.1.jar"/>
    <classpathentry kind="var" path="AXIS2_HOME/lib/annogen-0.1.0.jar"/>
    <classpathentry kind="var" path="AXIS2_HOME/lib/axiom-api-1.2.7.jar"/>
    <classpathentry kind="var" path="AXIS2_HOME/lib/axiom-dom-1.2.7.jar"/>
    ...
    

    So then you can copy those lines and paste them in the obvious place in the actual .classpath file.

    0 讨论(0)
  • 2020-12-15 06:26

    My colleague implemented a classpath container which recursivly looks for jars in a given directory within the workspace, have a look at http://openscada.org/2010/05/31/adding-a-directory-as-class-path-to-eclipse/

    The update site can be found at http://repo.openscada.org/p2/bob/R

    The plugin is licensed unter LGPL V3 and you can find the source code under https://github.com/ctron/org.openscada.bob

    0 讨论(0)
  • 2020-12-15 06:28

    You can use a User Library in Eclipse can be a useful way to organize a set of jar files. If you have a set of jar files that you use in several projects, you can create a User Library to reference the set of jar files. As a result, all you would need to include in your project's build path is the User Library rather than all the individual jar files.

    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/User Library name"/>
    

    http://www.avajava.com/tutorials/lessons/what-is-a-user-library-and-how-do-i-use-it.html;jsessionid=ACD75E0A035BDC3AC656B481A7830FB6

    0 讨论(0)
提交回复
热议问题