当前位置: 首页 > 知识库问答 >
问题:

包org.apache.hadoop.conf不存在

宋华美
2023-03-14

我是编译Hadoop代码的新手,知道这个问题已经被回答过多次了。但是,我仍然很难找到正确的类路径来编译WordCount.java代码。我正在运行一个CentOS版本7。

我的Hadoop版本是:

Hadoop 2.7.1 Subversion   
https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ecc87ccf4a0228f35af08fc56de536e6ce657a   
Compiled by jenkins on 2015-06-29T06:04Z  
Compiled with protoc 2.5.0  
From source with checksum fc0a1a23fc1868e4d5ee7fa2b28a58a  
This command was run using /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.1.jar

当我执行echo$path时,我得到了以下结果:

java version "1.7.0_91"
OpenJDK Runtime Environment (rhel-2.6.2.1.el7_1-x86_64 u91-b00)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk/
export PATH=$PATH:$JAVA_HOME
export HADOOP_INSTALL=/usr/local/hadoop 
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
WordCount.java:5: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.*;
^
WordCount.java:6: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.*;
^
WordCount.java:7: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.*;
^
WordCount.java:8: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.*;
^
WordCount.java:9: error: package org.apache.hadoop.mapreduce does not exist
import org.apache.hadoop.mapreduce.*;
^
WordCount.java:10: error: package org.apache.hadoop.mapreduce.lib.input does not exist
import org.apache.hadoop.mapreduce.lib.input.*;
^
WordCount.java:11: error: package org.apache.hadoop.mapreduce.lib.output does not exist
import org.apache.hadoop.mapreduce.lib.output.*;
^
WordCount.java:12: error: package org.apache.hadoop.util does not exist
import org.apache.hadoop.util.*;
^
WordCount.java:14: error: cannot find symbol
public class WordCount extends Configured implements Tool {
                               ^
  symbol: class Configured
WordCount.java:14: error: cannot find symbol
public class WordCount extends Configured implements Tool {
                                                     ^
  symbol: class Tool
WordCount.java:47: error: cannot find symbol
    public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
                                    ^
  symbol:   class Mapper
  location: class WordCount
WordCount.java:47: error: cannot find symbol
    public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
                                           ^
  symbol:   class LongWritable
  location: class WordCount
WordCount.java:47: error: cannot find symbol
    public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
                                                         ^
  symbol:   class Text
  location: class WordCount
WordCount.java:47: error: cannot find symbol
    public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
                                                               ^
  symbol:   class Text
  location: class WordCount
WordCount.java:47: error: cannot find symbol
    public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
                                                                     ^
  symbol:   class IntWritable
  location: class WordCount
WordCount.java:48: error: cannot find symbol
    private final static IntWritable one = new IntWritable(1);
                         ^
  symbol:   class IntWritable
  location: class Map
WordCount.java:49: error: cannot find symbol
    private Text word = new Text();
            ^
  symbol:   class Text
  location: class Map
WordCount.java:52: error: cannot find symbol
    public void map(LongWritable key, Text value,
                    ^
  symbol:   class LongWritable
  location: class Map
WordCount.java:52: error: cannot find symbol
    public void map(LongWritable key, Text value,
                                      ^
  symbol:   class Text
  location: class Map
WordCount.java:53: error: package Mapper does not exist
            Mapper.Context context) throws IOException, InterruptedException {
                  ^
WordCount.java:63: error: cannot find symbol
    public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
                                       ^
  symbol:   class Reducer
  location: class WordCount
WordCount.java:63: error: cannot find symbol
    public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
                                               ^
  symbol:   class Text
  location: class WordCount
WordCount.java:63: error: cannot find symbol
    public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
                                                     ^
  symbol:   class IntWritable
  location: class WordCount
WordCount.java:63: error: cannot find symbol
    public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
                                                                  ^
  symbol:   class Text
  location: class WordCount
WordCount.java:63: error: cannot find symbol
    public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
                                                                        ^
  symbol:   class IntWritable
  location: class WordCount
WordCount.java:66: error: cannot find symbol
    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
                       ^
  symbol:   class Text
  location: class Reduce
WordCount.java:66: error: cannot find symbol
    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
                                          ^
  symbol:   class IntWritable
  location: class Reduce
WordCount.java:66: error: cannot find symbol
    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
                                                               ^
  symbol:   class Context
  location: class Reduce
WordCount.java:17: error: cannot find symbol
    int res = ToolRunner.run(new WordCount(), args);
              ^
  symbol:   variable ToolRunner
  location: class WordCount
WordCount.java:22: error: cannot find symbol
    Path inputPath = new Path(args[0]);
    ^
  symbol:   class Path
  location: class WordCount
WordCount.java:22: error: cannot find symbol
    Path inputPath = new Path(args[0]);
                         ^
  symbol:   class Path
  location: class WordCount
WordCount.java:23: error: cannot find symbol
    Path outputPath = new Path(args[1]);
    ^
  symbol:   class Path
  location: class WordCount
WordCount.java:23: error: cannot find symbol
    Path outputPath = new Path(args[1]);
                          ^
  symbol:   class Path
  location: class WordCount
WordCount.java:25: error: cannot find symbol
    Configuration conf = getConf();
    ^
  symbol:   class Configuration
  location: class WordCount
WordCount.java:25: error: cannot find symbol
    Configuration conf = getConf();
                         ^
  symbol:   method getConf()
  location: class WordCount
WordCount.java:26: error: cannot find symbol
    Job job = new Job(conf, this.getClass().toString());
    ^
  symbol:   class Job
  location: class WordCount
WordCount.java:26: error: cannot find symbol
    Job job = new Job(conf, this.getClass().toString());
                  ^
  symbol:   class Job
  location: class WordCount
WordCount.java:26: error: cannot find symbol
    Job job = new Job(conf, this.getClass().toString());
                                ^
  symbol: method getClass()
WordCount.java:28: error: cannot find symbol
    FileInputFormat.setInputPaths(job, inputPath);
    ^
  symbol:   variable FileInputFormat
  location: class WordCount
WordCount.java:29: error: cannot find symbol
    FileOutputFormat.setOutputPath(job, outputPath);
    ^
  symbol:   variable FileOutputFormat
  location: class WordCount
WordCount.java:33: error: cannot find symbol
    job.setInputFormatClass(TextInputFormat.class);
                            ^
  symbol:   class TextInputFormat
  location: class WordCount
WordCount.java:34: error: cannot find symbol
    job.setOutputFormatClass(TextOutputFormat.class);
                             ^
  symbol:   class TextOutputFormat
  location: class WordCount
WordCount.java:35: error: cannot find symbol
    job.setMapOutputKeyClass(Text.class);
                             ^
  symbol:   class Text
  location: class WordCount
WordCount.java:36: error: cannot find symbol
    job.setMapOutputValueClass(IntWritable.class);
                               ^
  symbol:   class IntWritable
  location: class WordCount
WordCount.java:37: error: cannot find symbol
    job.setOutputKeyClass(Text.class);
                          ^
  symbol:   class Text
  location: class WordCount
WordCount.java:38: error: cannot find symbol
    job.setOutputValueClass(IntWritable.class);
                            ^
  symbol:   class IntWritable
  location: class WordCount
WordCount.java:48: error: cannot find symbol
    private final static IntWritable one = new IntWritable(1);
                                               ^
  symbol:   class IntWritable
  location: class Map
WordCount.java:49: error: cannot find symbol
    private Text word = new Text();
                            ^
  symbol:   class Text
  location: class Map
WordCount.java:51: error: method does not override or implement a method from a supertype
    @Override
    ^
WordCount.java:68: error: cannot find symbol
    for (IntWritable value : values) {
         ^
  symbol:   class IntWritable
  location: class Reduce
WordCount.java:72: error: cannot find symbol
    context.write(key, new IntWritable(sum));
                           ^
  symbol:   class IntWritable
  location: class Reduce
WordCount.java:65: error: method does not override or implement a method from a supertype
    @Override
    ^
52 errors

有人能给我指个正确的方向吗?谢谢你。

共有1个答案

江航
2023-03-14

您可以像下面这样运行它:

javac WordCount.java -cp $(hadoop classpath)

如果出现以下错误:

ZSH:未找到命令:hadoop

javac WordCount.java -cp $(/usr/local/Cellar/hadoop/2.8.0/bin/hadoop classpath)
 类似资料:
  • 我正在尝试在intelliJ中制作一个jar文件。我的目录中保存了所有的java类是C:\transProject\src\cege。在cege中有一个包用户界面,其中有一个类guiMain。而且我已经在我的Main()类中导入了guiMain()。 我有以下代码行: 包装cege; 进口cege。用户界面。圭曼; 当我在intelliJ中使用终端并编写命令时: C:\trafficProject

  • 我正在研究如何从命令行编译Java。我得到的是: 我得到的是: HelloWorld: inner.java 内部2.Java 我正在用编译这个文件,这个文件工作得很好。 现在我的理解是,因为helloworld.java在它的import语句中引用了其他包,所以javac会去编译这些包。我猜对于所有的Java包,javac在内部都有。 反正-如果我在helloworld.java中添加以下导入行

  • 我得到了一个可怕的软件包,它根本不存在,简直要了我的命。代码很好,我在市场上有运行代码的应用程序。 现在它正在影响简单的应用程序。o.0 <代码>R.string。app_name是错误的my 。应该对应于R.java

  • 我使用的是openjdk版本“1.8.0_252”,我还单独安装了javafx,目前的版本是javafx.version=11.0.2-internal。我已经在IntelliJ中添加了javafx库路径。编写代码javafx对时没有错误。但是,当我使用sudo mvn clean install构建项目时,我出现了以下错误,导致构建失败:

  • 我是新手,正在尝试为JavaCard开发一个applet。当我从一个网站上跟踪一个示例代码时,我被困在这里了。NetBeans表示JavaCardX.Framework包不存在。 我就不会正确地链接Java经典Jar文件。请帮帮我