简体   繁体   English

如何将JAR永久添加到Eclipse?

[英]How do I permanently add JARs to Eclipse?

I am using Eclipse Mars 4.5.1. 我正在使用Eclipse Mars 4.5.1。 I have a collection of Apache Batik SVG 1.7 JARs that are used by my projects. 我有我的项目使用的Apache Batik SVG 1.7 JAR的集合。 Rather than repeatedly importing the same JARs to each individual project now and in the future, I want to import the JARs permanently into Eclipse. 我不想现在和将来重复将相同的JAR导入每个单独的项目,而是希望将JAR永久导入到Eclipse。

I am guessing that the best way to do that is to import the JARs into the Java System Library ( eclipse/jre/lib ) which is imported into every Java project by default. 我猜测最好的方法是将JAR导入Java系统库( eclipse/jre/lib ),该eclipse/jre/lib默认情况下会导入到每个Java项目中。 Is that right? 那正确吗? How can I do this? 我怎样才能做到这一点?

I don't recommend to do this. 我不建议这样做。 Don't add third party jars to system library. 不要将第三方jar添加到系统库中。 System library is not supposed to store them, and they will be exposed to all projects and apps. 系统库不应存储它们,它们将对所有项目和应用程序公开。 There is a user library concept for this. 有一个user library概念。

A user library is a set of JAR files. 用户库是一组JAR文件。 A user library can be added to a projects build path through the build path properties page. 可以通过构建路径属性页面将用户库添加到项目构建路径。 The User Libraries preference page allows to define, edit, import, export, or remove user libraries. “用户库”首选项页面允许定义,编辑,导入,导出或删除用户库。

Once you create a user library, it can be added it to any of IDE projects. 创建用户库后,可以将其添加到任何IDE项目中。

But it is not a good approach to dependency management to tie dependencies to IDE and/or environment. 但是将依赖关系绑定到IDE和/或环境不是一种好的依赖关系管理方法。 Better use dependency management and build tools as Ivy, Maven, Gradle. 更好地使用依赖管理和构建工具,如Ivy,Maven,Gradle。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM