8

In Eclipse, the following import...

import org.apache.commons.net.ftp.FTPClient;

...produces the following error message...

The import org.apache cannot be resolved

I do not know how to import, nor where to download the import (if necessary). I might need a click-by-click set of Eclipse directions to resolve this.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Roger
  • 1,461
  • 5
  • 14
  • 15

3 Answers3

14

Steps:-

  1. Download this commons-net.jar file

  2. Extract the zip file

  3. Copy the Jar file

  4. Place the file in lib folder of your project.

  5. Right click on the project

  6. On left side of list, click on "Java Build Path"

  7. Click on Libraries tab and Click on "Add Jar"

  8. Browse the Commons-net.jar file and click on insert

Siva Charan
  • 17,940
  • 9
  • 60
  • 95
  • 3
    Alternative for steps 5-8: rightclick JAR file in project, *Build Path > Add to Build Path*. – BalusC Nov 26 '11 at 18:39
  • Thanks. When you say 'Place the file in lib...', In eclipse, I assume the 'lib' folder you wrote is the 'JRE System Library' folder(?). Assuming that is correct, if I right click on 'JRE System Library', there are many options. I will guess* it is one of the 'General' options(?). Under 'General',I will guess* the correct option is 'File System'(?). – Roger Nov 26 '11 at 18:54
  • Here **lib** folder is the project related folder. So it requires all others steps 5-8 – Siva Charan Nov 26 '11 at 18:58
  • Thanks again. For future reference, the folder referred to as 'lib' is a top-level 'blue folder' in Eclipse. Please correct me if I am wrong. Also, what is the Google or location strategy for finding a particular jar file? – Roger Nov 26 '11 at 19:06
  • The `/lib` folder is just a folder which you create yourself (rightclick project, *New > Folder*). You can of course also put the JAR straight in project root structure. The `/lib` folder is not mandatory, but just a common practice to collect all dependency JARs in one place. Do for sure not put it in "JRE System Library" or something. – BalusC Nov 27 '11 at 23:53
6

Here's the official Apache download site for Commons Net.

Once you've picked and extracted the appropriate version, set a dependency in your Eclipse project:

  • Right-click the project and choose "Properties"
  • Choose "Java Build Path" from the resulting popup
  • Set up the dependency in the "Libraries" tab.

The dependency does not need to be local to your project, but may be.

If you'd like a project-relative library, drop the jar into an appropriate project-relative location. For project libraries, choose "Add Jars" in the "Libraries" tab; for external libraries, choose "Add External Jars".

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
3

If you're working in a Maven project, you will need to add commons-net as a dependency

     <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.6</version>
    </dependency>
Vinnie James
  • 5,763
  • 6
  • 43
  • 52