如何定义hadoop类路径?

pkwftd7m  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(361)

这段代码来自hadoop和spark课程。我正在vm(hdp沙盒)上运行它

[root@sandbox-hdp Lesson-5.3_hadoop-grep]# javac -classpath /usr/lib/hadoop/hadoop-core.jar -d Grep_classes Grep.java
Grep.java:22: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configuration;
                             ^
Grep.java:23: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configured;
                             ^
Grep.java:24: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FileSystem;
                           ^
Grep.java:25: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;

我是hadoop新手,如何定义类路径?
如果我尝试

hadoop classpath

输出

/usr/hdp/3.0.1.0-187/hadoop/conf:/usr/hdp/3.0.1.0-187/hadoop/lib/*:/usr/hdp/3.0.1.0-187/hadoop/.//*:/usr/hdp/3.0.1.0-187/hadoop-hdfs/./:/usr/hdp/3.0.1.0-187/hadoop-hdfs/lib/*:/usr/hdp/3.0.1.0-187/hadoop-hdfs/.//*:/usr/hdp/3.0.1.0-187/hadoop-mapreduce/lib/*:/usr/hdp/3.0.1.0-187/hadoop-mapreduce/.//*:/usr/hdp/3.0.1.0-187/hadoop-yarn/./:/usr/hdp/3.0.1.0-187/hadoop-yarn/lib/*:/usr/hdp/3.0.1.0-187/hadoop-yarn/.//*:/usr/hdp/3.0.1.0-187/tez/*:/usr/hdp/3.0.1.0-187/tez/lib/*:/usr/hdp/3.0.1.0-187/tez/conf:/usr/hdp/3.0.1.0-187/tez/conf_llap:/usr/hdp/3.0.1.0-187/tez/doc:/usr/hdp/3.0.1.0-187/tez/hadoop-shim-0.9.1.3.0.1.0-187.jar:/usr/hdp/3.0.1.0-187/tez/hadoop-shim-2.8-0.9.1.3.0.1.0-187.jar

如何更改javac行?

vjhs03f7

vjhs03f71#

您可以在hadoop-env.sh中导出hadoop\u类路径。您可以向hadoop\u类路径添加更多jar。
稍后在运行作业之前,在shell中运行以下命令。

export HADOOP_CLASSPATH=$(hadoop classpath)
echo $HADOOP_CLASSPATH

参考请参见

相关问题