Using java library in eclipse

左心房为你撑大大i 提交于 2019-12-01 08:38:49

问题


I'm a bit new to eclipse and want to use the following libraries so that I can use their implemented objects (HttpClient and Java csv). How do I import these libraries so that I can write some java with them?

http://hc.apache.org/downloads.cgi

http://sourceforge.net/projects/javacsv/


回答1:


What you're looking to do is add the libraries to your project's build path (the class path that will be used while compiling). In Eclipse, you can do this by right-clicking your project and choosing Properties (or hitting [Alt]+[Enter] when the project is selected in Project Explorer, Navigator or Package Explorer views) and then Java Build Path from the sidebar and the Libraries tab where you can add JARs.

Note the difference between Add JARs and External JARs is that External JARs will add an external dependency in your project since the absolute path to the JAR on your filesystem will be put into your project's configuration. With Add JARs you can select JARs from within your workspace.

I find it to be a good practice to create a lib folder (at the same level as my src folder) and put all my JARs in there and then add them to the build path with the Add JARs option. This makes the project portable since there are only relative paths referring to resources within the project rather than absolute paths or resources from other workspace projects.




回答2:


You add the .jar files you want to use in your projects build path. You access this windows by right-clicking your project. Choosing "Build path" -> "Configure build path".



来源:https://stackoverflow.com/questions/5285986/using-java-library-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!