有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何在标准java程序中导入okhttp?

我正试图在java程序中导入okhttp包,但我一直找不到该怎么做

现在,我已经在我的计算机上下载了这个包(从下面的git hub链接:https://github.com/square/okhttp),但我不知道如何在我的程序中导入这个包

关于如何使用这个软件包有什么建议吗


共 (1) 个答案

  1. # 1 楼答案

    下载依赖项

    您可以从maven central下载jar文件

    download jar

    添加到项目类路径

    然后需要将其添加到类路径中

    如果您是从终端编译,请放置okhttp。jar文件与Java类位于同一目录中。然后可以运行以下命令

    javac -cp okhttp-2.7.5.jar MyClass.java
    

    You need to replace okhttp-2.7.5.jar with the actual name of the okhttp jar, and replace MyClass.java with the actually name of your Java file

    日食

    1. 右键单击project
    2. 构建路径
    3. 配置生成路径
    4. 添加外部罐子
    5. 选择jar文件

    right click add external jar

    The method outlined above is the simplest way to add dependencies to a project. However, there are specific technologies such as Ant, Maven, and Gradle which allow you to include dependencies through XML or other DSL's