gpt4 book ai didi

java - 无法将java文件编译为hadoop的类文件

转载 作者:可可西里 更新时间:2023-11-01 15:29:56 25 4
gpt4 key购买 nike

我正在使用 hadoop 2.6.4 并尝试使用以下命令编译 java 文件:

javac -classpath $HADOOP_HOME/share/hadoop/common/hadoop-common-2.6.4.jar:$HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.4.jar:$HADOOP_HOME/share/hadoop/common/lib/commons-cli-1.2.jar -d class_files *.java

但是由于缺少 hadoop 包,这不是编译文件:

GraphSearch.java:28: error: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configured;
^
GraphSearch.java:29: error: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;
^
GraphSearch.java:30: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.IntWritable;
^
GraphSearch.java:31: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.LongWritable;
^
GraphSearch.java:32: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
^
GraphSearch.java:33: error: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.*;
^
GraphSearch.java:34: error: package org.apache.hadoop.util does not exist
import org.apache.hadoop.util.Tool;
^
GraphSearch.java:35: error: package org.apache.hadoop.util does not exist
import org.apache.hadoop.util.ToolRunner;
^
GraphSearch.java:52: error: cannot find symbol
public class GraphSearch extends Configured implements Tool {

尝试使用以下命令设置类路径,不确定是否正确:

export CLASSPATH=$CLASSPATH:/usr/local/hadoop/share/hadoop/common/hadoop-common-2.6.4.jar:$/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.4.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-cli-1.2.jar

请帮忙!

最佳答案

试试这个:

export PATH=$PATH:$HADOOP_HOME/bin

javac -cp $(hadoop classpath) -d class_files *.java

简短而贴心,但请确保您已经设置了 HADOOP_HOME 环境变量。

关于java - 无法将java文件编译为hadoop的类文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35929475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com