Java 如何在 Eclipse 和 Android Studio 中设置类路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31936254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the class path in Eclipse and Android Studio
提问by Sweeper
I've heard that you can use classpath
to use classes in other libraries. I googled about this and all results tell me to use the command line to compile the program and specify a classpath. But who would use command line to compile java programs nowadays?
我听说您可以使用classpath
其他库中的类。我搜索了这个,所有结果都告诉我使用命令行来编译程序并指定一个类路径。但是现在谁会用命令行来编译java程序呢?
I am using eclipse and Android Studio. I mean they are IDEs so they surely can set the classpath very easily, right?
我正在使用 Eclipse 和 Android Studio。我的意思是它们是 IDE,所以它们肯定可以很容易地设置类路径,对吗?
Also, I want to know the word "library" in this context is just a jar file , right?
另外,我想知道在这种情况下“库”这个词只是一个 jar 文件,对吗?
采纳答案by Sumit Singh
In Eclipse:
在日食中:
Right-Clickon the Project → Build Path → Configure Build Path
. Under Libraries tab, click Add Jars or Add External JARs
and give the Jar.
右键单击在Project → Build Path → Configure Build Path
。在库选项卡下,单击Add Jars or Add External JARs
并提供 Jar。
Image from link
图片来自链接
Android Studio:from Android Studio: Add jar as library?
Android Studio:来自Android Studio:将 jar 添加为库?
回答by Raghav Simlote
In eclipse, Right Click on Project -> Properties -> Java Build Path -> Add Class Folder or Simply copy your jar file to the libs folder in your project. Right click on jar file, Select "Build Path" then click "Add to build path".
在 eclipse 中,右键单击 Project -> Properties -> Java Build Path -> Add Class Folder 或简单地将 jar 文件复制到项目中的 libs 文件夹。右键单击 jar 文件,选择“构建路径”,然后单击“添加到构建路径”。
In Android Studio, Simply copy your jar file to the libs folder in your project. Right Click on Project -> Module Settings Select your project from the left and click on "+" sign at the bottom and select "jars or directories". Go to your project's libs folder and select the jar file which you have copied in that folder in step 1 and press OK Just make sure to check the box and then press "Apply" or "Ok" button to finish the process.
在 Android Studio 中,只需将 jar 文件复制到项目中的 libs 文件夹即可。右键单击项目 -> 模块设置 从左侧选择您的项目,然后单击底部的“+”号并选择“jars 或目录”。转到您项目的 libs 文件夹并选择您在步骤 1 中复制到该文件夹中的 jar 文件,然后按 OK 只需确保选中该框,然后按“应用”或“确定”按钮完成该过程。