WriteFile.java:1: error: package org.apache.hadoop.conf does not e

WriteFile.java:1: error: package org.apache.hadoop.conf does not exist

环境变量ClassPath问题解决方案

WriteFile.java:1: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configuration;
                             ^
WriteFile.java:2: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FSDataOutputStream;
                           ^
WriteFile.java:3: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FileSystem;
                           ^
WriteFile.java:4: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;
                           ^
WriteFile.java:7: error: cannot find symbol
		Configuration conf=new Configuration();
		^
  symbol:   class Configuration
  location: class WriteFile
WriteFile.java:7: error: cannot find symbol
		Configuration conf=new Configuration();
		                       ^
  symbol:   class Configuration
  location: class WriteFile
WriteFile.java:8: error: cannot find symbol
		FileSystem hdfs = FileSystem.get(conf);
		^
  symbol:   class FileSystem
  location: class WriteFile
WriteFile.java:8: error: cannot find symbol
		FileSystem hdfs = FileSystem.get(conf);
		                  ^
  symbol:   variable FileSystem
  location: class WriteFile
WriteFile.java:9: error: cannot find symbol
		Path dfs = new Path("/weather.txt");
		^
  symbol:   class Path
  location: class WriteFile
WriteFile.java:9: error: cannot find symbol
		Path dfs = new Path("/weather.txt");
		               ^
  symbol:   class Path
  location: class WriteFile
WriteFile.java:10: error: cannot find symbol
		FSDataOutputStream outputStream = hdfs.create(dfs);
		^
  symbol:   class FSDataOutputStream
  location: class WriteFile
11 errors

配置文件 vi /etc/profile

JAVA_HOME=/usr/jdk1.8.0_141
export HADOOP_HOME=/usr/local/hadoop-2.7.3
export JRE_HOME=/usr/jdk1.8.0_141//jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$HADOOP_HOME/share/hadoop/common/*:$HADOOP_HOME/share/hadoop/common/lib/*
export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib:$HADOOP_HOME/lib/native"
经验分享 程序员 微信小程序 职场和发展