搞定了hadoop配置之後,可以寫程式碼執行了,首先要配一下CLASS_PATH,修改/etc/profile
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386 export HADOOP_INSTALL=/home/zhanglanyun/workspace/hadoop export PATH=$PATH:$HADOOP_INSTALL/bin export CLASSPATH=.:$JAVA_HOME/lib/:$HADOOP_INSTALL/hadoop-core-1.1.2.jar
然後編譯程式碼
javac A.java ...
然後把所有的class打包成一個jar檔案
jar cvf B.jar m.class n.class
配置hadoop的輸入輸出
hadoop fs mkdir /tmp/input
hadoop fs -put *.txt /tmp/input
然後執行命令即可
hadoop jar workspace/srcanddata/tomwhite-hadoop-book-32dae01/ch02/src/main/java/MaxTemperature.jar MaxTemperature /tmp/input/sample.txt /tmp/output
然後一個簡單的hadoop程式就跑起來了