Importing Java Library JAR into eclipse

巧了我就是萌 提交于 2020-01-06 20:01:22

问题


I'm currently trying to implement a browser with pipelining feature in it. The problem is in order to code the HTTP pipeline, i need the support of a library. I tried to import it to my workspace by using Project - > properties -> Java build path ->addJar. And I was able to add it successfully. But now my problem is, even though it is added to my workspace it doesnt let me run this code. It gives me errors as if I have not imported the library:

package com.test.download;
import java.util.Collections;
import org.factor45.*;
    public class Example {

        // Execute the request
        HttpRequestFuture<String> future = client.execute("hotpotato.factor45.org", 80, request,
                                                          new BodyAsStringProcessor());
        future.addListener(new HttpRequestFutureListener<String>() {
            @Override
            public void operationComplete(HttpRequestFuture<String> future) throws Exception {
                System.out.println(future);
                if (future.isSuccessfulResponse()) {
                    System.out.println(future.getProcessedResult());
                }
                client.terminate();
            }
        });
    }

This is available in the same website which provided me the library for the above code. "Here" is the website for your reference. Also you can find the JAR file inside this website.

Please help me to figure out the problem. If you solve this you are a life saver! Thanks in advance!


回答1:


Try this:

Properties >> Java Build Path >> Libraries >> Add External JARs... Then select the library



来源:https://stackoverflow.com/questions/11275760/importing-java-library-jar-into-eclipse

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