简体   繁体   中英

How to install an open source library to Eclipse?

I am trying to install this library to my java project. It's a port of the socket.io client for nodejs. 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?)?

If you are using maven, it's simple.

  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:

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

    mvn eclipse:eclipse

* If the project own other dependencies (seems need engine.io-client.java ), repeat step 1~3.

Better make a jar if they don't provide one, but usually you will find a jar to download. To compile yours: http://docs.oracle.com/javase/tutorial/deployment/jar/

After you can link source to jar for debugging it.

There are multiple options, but as I could not see a link to a built JAR, I would do the following:

  • Checkout the github project directly in eclipse
  • Export as JAR
  • Import as JAR in my personal project

This has the advantage that you already have a JAR so you can use it in multiple project. 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)

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