简体   繁体   English

如何将开放源代码库安装到Eclipse?

[英]How to install an open source library to Eclipse?

I am trying to install this library to my java project. 我正在尝试将此安装到我的Java项目中。 It's a port of the socket.io client for nodejs. 它是用于nodejs的socket.io客户端的端口。 Because I am provided with the source files, how should I import it? 因为提供了源文件,应该如何导入它? Do I create a package within my project? 我是否在项目中创建包? Or convert the java files into an executable jar file and import it as a library (how would I do that?)? 还是将Java文件转换为可执行的jar文件并将其作为库导入(我该怎么做?)?

If you are using maven, it's simple. 如果您正在使用Maven,这很简单。

  1. Get it 得到它

    git clone https://github.com/nkzawa/socket.io-client.java.git

  2. Install to your local repo 安装到本地仓库

    cd socket.io-client.java

    mvn install

  3. Add this jar to your project pom.xml: 将此jar添加到您的项目pom.xml中:

      <dependency> <groupId>com.github.nkzawa</groupId> <artifactId>socket.io-client</artifactId> <version>0.1.0-SNAPSHOT</version> </dependency> 
  4. Import to Eclipse 导入到Eclipse

    mvn eclipse:eclipse

* If the project own other dependencies (seems need engine.io-client.java ), repeat step 1~3. *如果项目拥有其他依赖项(似乎需要engine.io-client.java ),请重复步骤engine.io-client.java

Better make a jar if they don't provide one, but usually you will find a jar to download. 如果他们不提供一个jar,最好制作一个jar,但是通常您会找到一个jar下载。 To compile yours: http://docs.oracle.com/javase/tutorial/deployment/jar/ 要编译您的文件: http : //docs.oracle.com/javase/tutorial/deployment/jar/

After you can link source to jar for debugging it. 之后,您可以将源链接到jar进行调试。

There are multiple options, but as I could not see a link to a built JAR, I would do the following: 有多个选项,但是由于看不到构建的JAR的链接,我将执行以下操作:

  • Checkout the github project directly in eclipse 直接在eclipse中签出github项目
  • Export as JAR 导出为JAR
  • Import as JAR in my personal project 在我的个人项目中作为JAR导入

This has the advantage that you already have a JAR so you can use it in multiple project. 这样做的好处是您已经有一个JAR,因此可以在多个项目中使用它。 When you have checked out the project in Eclipse you can also link to the project to your project so you don't need to generate a JAR (and can update it more often as well without generate a JAR) 在Eclipse中签出项目后,您还可以将项目链接到您的项目,因此您无需生成JAR(并且可以更频繁地更新它而无需生成JAR)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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