如何在Eclipse中导入一个jar ?
当前回答
您可以通过右键单击Project→Build Path→Configure Build Path在Eclipse中添加一个jar。在Libraries选项卡下,单击Add Jars或Add External Jars并给出Jar。这里有一个简单的演示。
上述解决方案显然是一个“快速”的解决方案。然而,如果您正在处理一个需要向源代码控制存储库提交文件的项目,我建议将Jar文件添加到源代码控制存储库中的专用库文件夹中,并引用上面提到的少数或全部Jar文件。
其他回答
两个选择:
1/来自项目:
2/如果你已经导入了其他jar,从“References Libraries”目录:
两者都会引导你进入这个屏幕,在这里你可以管理你的库:
以下是步骤:
click File > Import. The Import window opens. Under Select an import source, click J2EE > App Client JAR file. Click Next. In the Application Client file field, enter the location and name of the application client JAR file that you want to import. You can click the Browse button to select the JAR file from the file system. In the Application Client project field, type a new project name or select an application client project from the drop-down list. If you type a new name in this field, the application client project will be created based on the version of the application client JAR file, and it will use the default location. In the Target runtime drop-down list, select the application server that you want to target for your development. This selection affects the run time settings by modifying the class path entries for the project. If you want to add the new module to an enterprise application project, select the Add project to an EAR check box and then select an existing enterprise application project from the list or create a new one by clicking New. Note: If you type a new enterprise application project name, the enterprise application project will be created in the default location with the lowest compatible J2EE version based on the version of the project being created. If you want to specify a different version or a different location for the enterprise application, you must use the New Enterprise Application Project wizard. Click Finish to import the application client JAR file.
在eclipse中,我包含了一个压缩jar文件,即zip文件。Eclipse允许我将这个压缩文件添加为外部jar,但当我试图访问jar中的类时,它们没有显示出来。
经过大量的尝试和错误,我发现使用zip格式是行不通的。当我添加一个jar文件时,它为我工作了。
系统路径下的Jar文件为:
C: \ oraclexe app \ oracle产品10。2。0 \ server \ jdbc lib \ ojdbc14。jar
Ojdbc14.jar (jar文件)
要在Eclipse IDE中导入jar文件,请遵循以下步骤。
右键单击项目 选择生成路径 单击Configure Build Path 单击Libraries,选择Modulepath,然后选择Add External jar 从所需的文件夹中选择jar文件 单击“应用”和“确定”
只是对将jar导入Eclipse(插件开发)项目的注释:
In case you are developing Eclipse plug-ins, it makes sense to use Eclipse's native bundling mechanism instead of just importing the jar into a plug-in project. Eclipse (or better its underlying OSGi runtime, Equinox) uses so-called bundles which contain some more information than plain jars (e.g., version infos, dependencies to other bundles, exported packages; see the MANIFEST.MF file). Because of this information, OSGi bundles can be dynamically loaded/unloaded and there is automatic dependency resolution available in an OSGi/Eclipse runtime. Hence, using OSGi bundles instead of plain jars (contained inside another OSGi bundle) has some advantages.
(顺便说一句:Eclipse插件与OSGi包是一回事。)
很有可能有人已经将某个(第三方)库绑定为OSGi包。你可能想看看下面的bundle仓库:
http://www.springsource.com/repository/app/ http://download.eclipse.org/tools/orbit/downloads/ http://www.osgi.org/Repository/HomePage
推荐文章
- 在Java中使用UUID的最重要位的碰撞可能性
- 转换列表的最佳方法:map还是foreach?
- 如何分割逗号分隔的字符串?
- Java字符串—查看字符串是否只包含数字而不包含字母
- Mockito.any()传递带有泛型的接口
- 在IntelliJ 10.5中运行测试时,出现“NoSuchMethodError: org.hamcrest. matcher . descripbemismatch”
- 使用String.split()和多个分隔符
- Java数组有最大大小吗?
- 在Android中将字符串转换为Uri
- 从JSON生成Java类?
- 为什么java.util.Set没有get(int index)?
- Swing和AWT的区别是什么?
- 为什么Java流是一次性的?
- 四舍五入BigDecimal *总是*有两位小数点后
- 设计模式:工厂vs工厂方法vs抽象工厂