Updated on 2022-09-14 GMT+08:00

Obtaining and Importing a Sample Project

Scenario

HDFS provides sample projects for multiple scenarios to help you quickly learn HDFS projects.

The following procedure describes how to import HDFS sample code.

Procedure

  1. Download the sample project to the local computer by referring to Obtaining a Sample Project.
  2. Import the sample project to the Eclipse development environment.

    1. Method 1: Open Eclipse and choose File > New > Java Project.
    2. Deselect Use default location and click Browse.

      The Browse Folder dialog box is displayed.

    3. Select the hdfs-examples sample project folder, and click OK.
    4. In the New Java Project window, click Finish.
    5. Method 2: Open Eclipse, choose File > Import... > Existing maven Projects into Workspace > Next, and click Browse on the next page. The Browse Folder dialog box is displayed.
    6. Select the hdfs-examples sample project folder, and click OK.
    7. In the Import window, click Finish.

  3. Set an Eclipse text file encoding format to prevent garbled characters.

    1. On the Eclipse menu bar, choose Window > Preferences.

      The Preferences window is displayed.

    2. In the navigation tree, choose General > Workspace. In the Text file encoding area, select Other and set the value to UTF-8. Click Apply and then OK. Figure 1 shows the settings.
      Figure 1 Setting the Eclipse encoding format