如何加外部jar

http://www.wonderhowto.com/how-to-add-jars-project-build-paths-eclipse-java-088654/

Adding External JARs

Note: It is much better to reference jars that exist in your project or in other projects - this allows you to check in all of your dependencies to your version control system. (You are using version control, right?)

Use one of the following methods.

 

Method 1

This is the preferred method, as it allows different developers of a common project to locate their external jars in different places.

  1. Right click the project name and navigate to Build Path.
  2. Select Configure Build Path... and the project properties window will appear showing your build path configurations.
  3. Click Add Variable...
  4. Click Configure Variables...
  5. Click New...
  6. Type a name for the new variable. For example, if these are jars for Tomcat, perhaps call it TOMCAT_JARS
  7. Browse to the directory that contains the jar for the path. (You can also select a specific jar file for the variable, if you prefer.)
  8. Click Ok to define the variable
  9. Click Ok to close the preferences dialog
  10. Select the variable from the list
  11. Click Extend...
  12. Select the jar(s) that you want to add to the classpath
  13. Click Ok to close the extend dialog
  14. Click Ok to close the new classpath variable dialog
  15. Click Ok to close the build path setup dialog

If you share the project with someone else, they must also define the variable. They can define it under Window->Preferences->Java->Build Path->Classpath Variables

 

Method 2

Note that if you use this method, the external jar will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.

  1. Right click the project name and navigate to Build Path.
  2. How To Add JARs to Project Build Paths in Eclipse (Java)Select Add External Archives... 
  3. Locate and select the JARs you want and click Open. The JARs will now appear in Referenced Libraries.

 

Method 3

Note that if you use this method, the external jar will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.

  1. Right click the project name and navigate to Build Path.
  2. Select Configure Build Path... and the project properties window will appear showing your build path configurations.
  3. Select the Libraries tab.
  4. Click Add External JARs...
  5. How To Add JARs to Project Build Paths in Eclipse (Java)Locate and select the JARs you want and click Open. The JARs will now appear in the list of libraries in the build path.  
  6. Click OK to close the properties window. The JARs will now be in Referenced Libraries.


See more: How To Add JARs to Project Build Paths in Eclipse - Java | Guide « Wonder How To http://www.wonderhowto.com/how-to-add-jars-project-build-paths-eclipse-java-088654/#ixzz1GoZJrm99
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值