Using HDFS from Java coding
While HDFS can be manipulated 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) applications 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 programming and compilation 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: