我如何利用java库?

时间:2022-09-23 07:55:52

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.

我的项目是开发网络分析工具,我决定使用JUNG库。但是我不知道如何开始使用它?我正在使用eclipse IDE,那么如何在eclipse中集成它?谢谢。

3 个解决方案

#1


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.

要在Eclipse中集成外部库,只需转到包浏览器侧视图,右键单击项目或项目中的某个文件,然后转到属性。在Java Build Path部分中,转到libraries选项卡并在那里添加库。这应该使它显示在您的构建路径中,以便它将与您的项目一起编译。

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

我应该提一下,如果它只是一个外部jar,只需单击Add External JARs而不是Add Library。

#2


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.

将jar文件拖到Eclipse中并将它们放在项目中(我相信你只有一个)。右键单击jar文件,然后选择“Add to Build Path”。然后应立即访问它。

#3


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

如果您正在使用eclipse插件甚至是eclipse-rcp应用程序,您应该创建一个仅包含此库的新插件项目。这很简单:只需打开向导即可创建一个新项目:File> New> Project ...> Plug-in Development>来自现有JAR存档的插件

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.

在任何其他情况下:直接在项目中创建库的副本(我建议:lib / jung.jar)并将该库添加到构建路径(右键单击库)或使用jar创建用户库(s )并将该用户库添加到项目构建路径中。

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.

折衷方案可能是创建一个仅包含库的项目,并将该项目添加到构建路径中。它是松散耦合,如用户库,但您可以将该项目导出到其他工作区或从其他工作区导入。

#1


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.

要在Eclipse中集成外部库,只需转到包浏览器侧视图,右键单击项目或项目中的某个文件,然后转到属性。在Java Build Path部分中,转到libraries选项卡并在那里添加库。这应该使它显示在您的构建路径中,以便它将与您的项目一起编译。

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

我应该提一下,如果它只是一个外部jar,只需单击Add External JARs而不是Add Library。

#2


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.

将jar文件拖到Eclipse中并将它们放在项目中(我相信你只有一个)。右键单击jar文件,然后选择“Add to Build Path”。然后应立即访问它。

#3


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

如果您正在使用eclipse插件甚至是eclipse-rcp应用程序,您应该创建一个仅包含此库的新插件项目。这很简单:只需打开向导即可创建一个新项目:File> New> Project ...> Plug-in Development>来自现有JAR存档的插件

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.

在任何其他情况下:直接在项目中创建库的副本(我建议:lib / jung.jar)并将该库添加到构建路径(右键单击库)或使用jar创建用户库(s )并将该用户库添加到项目构建路径中。

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.

折衷方案可能是创建一个仅包含库的项目,并将该项目添加到构建路径中。它是松散耦合,如用户库,但您可以将该项目导出到其他工作区或从其他工作区导入。