7

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?

Sweeper
  • 213,210
  • 22
  • 193
  • 313
  • "But who would use command line to compile java programs nowadays" - people who are learning about the classpath – Gimby Aug 11 '15 at 08:00
  • @Gimby You mean I _must_ use the command line? – Sweeper Aug 11 '15 at 08:02
  • Nobody is forcing you. It is in your best interest to learn about the classpath and the use of packages on the command line, yes. An IDE like Eclipse hides far too much from you. – Gimby Aug 11 '15 at 08:49
  • @Gimby What do I do if I want to use stuff from another library if I want to use eclipse – Sweeper Aug 11 '15 at 08:50
  • 1
    http://stackoverflow.com/search?q=eclipse+add+library . I'm not trying to be a meany here, you are not the first person to ask about these things so a search is all you need. – Gimby Aug 11 '15 at 08:56

1 Answers1

1

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.