OpenSource For You

Using HDFS from Java coding

-

While HDFS can be manipulate­d explicitly through user commands or implicitly as the input to or output from the Hadoop Mapoeduce job, you can also work with HDFS inside your own Java L C++ ( libhdfs api) applicatio­ns and use it as a general purpose file system for the cluster and the cloud.

fn this section, we will write a code to create a 'hello world' text file using Java and using Eclipse fDE. We will configure Eclipse for easy programmin­g and compilatio­n of the code. 1. Create a new Java project and make sure to use Oracle

Sun Java and no other, as shown in Figure 1. 2. Click on Next. 3. do to the Libraries tab and click on Add External JARS. Select all the jar files from hadoop/lib directory and hadoop-core.jar from the Hadoop root directory as shown in Figure 2. 4. Click on Finish and we are ready to create the class file to

say 'hello world' to HDFS. 5. Create a new Java class file and name it helloWorld. 6. Write the following code in the helloWorld class:

Newspapers in English

Newspapers from India