Eclipse buildpath automatically taking all JARs of a internal directory

后端 未结 10 1753
醉梦人生
醉梦人生 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:03

    Have you tried using a wildcard in the classpath? So you would use something like:

    javac MyApp.java -cp /some/path/to/libraries/*.jar
    

    I've not used java for a while so not sure if the above is possible, but it's what I would expect to be the syntax.

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

    Use Maven2, and use the Eclipse Maven2 plugin.

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

    I'm using workaround which I developed after reading similar question. I'm posting it here, because that question has a little bit different scope and it might not be obvious how to use suggestions written there.

    1. Create new dynamic web project (default settings is ok so it is fast)
    2. Delete directory "lib" under WebContent/WEB-INF/
    3. Recreate that directory, but create it as link to the directory in your main project where your jars are located
    4. Check Web App Libraries option on Order and Export tab in Java Build Path settings of your project
    5. Add this newly created project as a dependency to your main project

    It's irritating to do this for every lib directory in your project but it's better than adding jars manually every time you do svn update (from your luckier colleagues using Idea). It's a shame that Eclipse don't have this feature.

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

    Meaning that adding a new .jar file to this directory (and refreshing the project) updates the buildpath

    Sorry, Eclipse doesn't support this.

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

    Using a homemade "ClassPath Container" solves the problem but needs you to build an Eclipse-plugin : http://www.ibm.com/developerworks/edu/os-dw-os-eclipse-classpath.html

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

    AFAIK, there's no normal way to do this.

    If you really want, there's a little hack. Eclipse .classpath file is a very simple XML. You can write a script or ant task that goes over a directory, updates .classpath xml and refreshes the project.

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