简体   繁体   中英

How do I make use of java library?

My project is to develop a network analysis tool and I decided to use JUNG library. but I don't know how to get started and make use of it?I'm using eclipse IDE so how can I intergrate it in eclipse? thanks.

To integrate an external library in Eclipse, simply go to your package explorer side view, right click on your project or on some file within your project, and go to properties. In the Java Build Path section, go to the libraries tab and add your library there. That should make it show up in your build path so that it will compile with your project.

I should mention that if it's just an external jar, simply click Add External JARs instead of Add Library.

Drag the jar files into Eclipse and drop them on your project (I believe you have only one). Right click on the jar file, and choose "Add to Build Path". It should then be immediately accessible.

And just in case your working on a eclipse plugin or even an eclipse-rcp application, you should create a new plugin project that just contains this library. It's very simple: just open the wizard to create a new project: File > New > Project... > Plug-in Development > Plug-in from existing JAR archive

In any other case: create either a copy of the library directly in your project (I suggest: lib/jung.jar) and add that library to your buildpath (right-click on library) or create a User Library with the jar(s) and add that user library to the projects buildpath.

Advantage of user libraries: reusable in the same workspace & projects are loosely coupled to the dependencies (you can update a library without changing the project). Disadvantage: user libraries are defined in the workspace, so when you import the project to a different workspace, you'll break your dependencies.

A compromise might be to create one project that only contains libraries and add that project to he build paths. It's loose coupling like user libraries but you can export and import that project to to/from other workspaces.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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