How to set the class path in Eclipse and Android Studio

淺唱寂寞╮ 提交于 2019-12-01 01:47:38

问题


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?

I am using eclipse and Android Studio. I mean they are IDEs so they surely can set the classpath very easily, right?

Also, I want to know the word "library" in this context is just a jar file , right?


回答1:


In Eclipse:

Right-Click on the Project → Build Path → Configure Build Path. Under Libraries tab, click Add Jars or Add External JARs and give the Jar.

Image from link

Android Studio: from Android Studio: Add jar as library?

  1. Right click on the module in the left hand panel and choose Open Module Settings.
  2. On the left panel of the dialog, choose Libraries.
  3. Click the + sign above the panel second from the left -> Java
  4. Select your local jar and add it to the project.



回答2:


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".

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.



来源:https://stackoverflow.com/questions/31936254/how-to-set-the-class-path-in-eclipse-and-android-studio

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