hadoop 编译代码及运行
搞定了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程序就跑起来了