package org.apache.hadoop.conf does not exist after setting classpath

…衆ロ難τιáo~ 提交于 2019-12-22 04:17:19

问题


I am a beginner in hadoop using the hadoop's beginners guide book as a tutorial.

I am using a mac osx 10.9.2 and hadoop version 1.2.1

I have set all the appropriate class path, when I call echo $PATH in terminal:

Here is the result I get:

/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/oladotunopasina/hadoop-1.2.1/hadoop-core-1.2.1.jar:/Users/oladotunopasina/hadoop-1.2.1/bin:/usr/share/grails/bin:/usr/share/groovy/bin:/Users/oladotunopasina/.rvm/gems/ruby-2.1.1/bin:/Users/oladotunopasina/.rvm/gems/ruby-2.1.1@global/bin:/Users/oladotunopasina/.rvm/rubies/ruby-2.1.1/bin:/usr/local/heroku/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/oladotunopasina/.rvm/bin:/Users/oladotunopasina/.rvm/bin

I tried compiling WordCount1.java and I am getting the following error:

WordCount1.java:2: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configuration ;
                         ^
WordCount1.java:3: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;
                       ^
WordCount1.java:4: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.IntWritable;
                       ^
WordCount1.java:5: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
                       ^
WordCount1.java:6: package org.apache.hadoop.mapreduce does not exist
import org.apache.hadoop.mapreduce.Job;
                              ^
WordCount1.java:7: package org.apache.hadoop.mapreduce does not exist
import org.apache.hadoop.mapreduce.Mapper;
                              ^

Kindly help.


回答1:


The CLASSPATH variable is the way to tell applications, including the JDK tools(javac), where to look for user classes.

You can set this variable as given below and try compiling the class.

export CLASSPATH=$CLASSPATH:/Users/oladotunopasina/hadoop-1.2.1/hadoop-core-1.2.1.jar



回答2:


If you are using a build tools such as Maven, Gradle, sbt, etc.

You have to add the dependency plugin to your build file.

For Maven,per example, you have to add the following into your pom.xml

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-core</artifactId>
    <version>1.2.1</version>
</dependency>

You can find the dependency settings for other build tools here



来源:https://stackoverflow.com/questions/24390492/package-org-apache-hadoop-conf-does-not-exist-after-setting-classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!