1. Copy the plugin Hadoop-eclipse-plugin-2.6.2.jar to the plugins in the Eclipse installation directory
2. Restart Eclipse
Preparing Hadoop
3. Enter Map/reduce view mode
4. Storing data in a Hadoop distributed storage System
5. Connect to Hadoop
6. Create a Hadoop project
7. Create a class Mywordcount.java
Package Com.yc.hadoop;import Java.io.ioexception;import Org.apache.hadoop.conf.configuration;import Org.apache.hadoop.fs.path;import Org.apache.hadoop.io.intwritable;import Org.apache.hadoop.io.text;import Org.apache.hadoop.mapreduce.job;import Org.apache.hadoop.mapreduce.mapper;import Org.apache.hadoop.mapreduce.reducer;import Org.apache.hadoop.mapreduce.lib.input.fileinputformat;import Org.apache.hadoop.mapreduce.lib.output.fileoutputformat;public class Mywordcount {public static class Mywordcoun Tmapper extends Mapper<object, text, text, intwritable> {Private final static intwritable one = new Intwritable (1); Private text Word = new text (); public void Map (Object key, Text value, Context context) throws IOException, interruptedexception {S tring[] Words = value.tostring (). Split ("\\s"); for (String w:words) {word.set (w); ConteXt.write (Word, one); }}} public static class Mywordcountreducer extends Reducer<text, intwritable, Text, intwritable> {Private Intwritable result = new intwritable (); public void reduce (Text key, iterable<intwritable> values, context context) throws IOException, interruptedexception {int sum = 0; for (intwritable val:values) {sum + = Val.get (); } result.set (sum); Context.write (key, result); }} public static void Main (string[] args) throws Exception {Configuration conf = new Co Nfiguration (); Job Job = job.getinstance (conf, "Mywordcount"); Job.setjarbyclass (Mywordcount.class); Job.setmapperclass (Mywordcountmapper.class); Job.setcombinerclass (MywordcoUntreducer.class); Job.setreducerclass (Mywordcountreducer.class); Job.setoutputkeyclass (Text.class); Job.setoutputvalueclass (Intwritable.class); Fileinputformat.addinputpath (Job, New Path (Args[0])); Fileoutputformat.setoutputpath (Job, New Path (Args[1])); System.exit (Job.waitforcompletion (true)? 0:1); } }
8. Running the Hadoop project
Windows Eclipse configuration Hadoop plugin (iv)