0

在 W7 上安装 Haddop HDInsight 之后。无法编译具有 hadoop 特定实现的 java 程序。他们错误地说:

    c:\Hadoop\hadoop-1.1.0-SNAPSHOT\bin>javac -classpath `C:\Hadoop\hadoop-       1.1.0-SNA
    PSHOT\hadoop-core.jar` C:\Z\WordCount.java -d C:\Z
    C:\Z\WordCount.java:6: error: package org.apache.hadoop.fs does not exist
    import org.apache.hadoop.fs.Path;
                               ^
    C:\Z\WordCount.java:7: error: package org.apache.hadoop.conf does not exist
    import org.apache.hadoop.conf.*;
    ^
    C:\Z\WordCount.java:8: error: package org.apache.hadoop.io does not exist
    import org.apache.hadoop.io.*;
    ^
    C:\Z\WordCount.java:9: error: package org.apache.hadoop.mapred does not exist
    import org.apache.hadoop.mapred.*;
    ^
    C:\Z\WordCount.java:10: error: package org.apache.hadoop.util does not exist
            import org.apache.hadoop.util.*;
            ^
    C:\Z\WordCount.java:14: error: cannot find symbol
                public static class Map extends MapReduceBase implements Mapper<Long
    Writable, Text, Text, IntWritable> {
                                                ^
      symbol:   class MapReduceBase
      location: class WordCount
    C:\Z\WordCount.java:14: error: cannot find symbol
                public static class Map extends MapReduceBase implements Mapper<Long
    Writable, Text, Text, IntWritable> {
                                                                         ^
      symbol:   class Mapper
      location: class WordCount
    C:\Z\WordCount.java:14: error: cannot find symbol
                public static class Map extends MapReduceBase implements Mapper<Long
    Writable, Text, Text, IntWritable> {
                                                                                ^

最初我尝试做

javac c:/z/WordCount.java

然后也尝试了

    c:\Hadoop\hadoop-1.1.0-SNAPSHOT\bin>
    javac -classpath `C:\Hadoop\hadoop-1.1.0-SNAPSHOT\hadoop-core.jar` 
    C:\Z\WordCount.java -d C:\Z

即,给出一个类路径。

好吧,我不确定 javac 到底指向哪里

这是我的 hadoop 文件夹中的内容:

01/09/2014  06:39 PM    <DIR>          .
01/09/2014  06:39 PM    <DIR>          ..
10/22/2013  01:43 PM    <DIR>          .eclipse.templates
01/09/2014  06:41 PM    <DIR>          bin
10/22/2013  01:43 PM           135,891 build.xml
10/22/2013  01:43 PM            16,372 CHANGES.branch-1-win.txt
10/22/2013  01:43 PM           463,978 CHANGES.txt
10/22/2013  01:43 PM    <DIR>          conf
10/22/2013  01:43 PM    <DIR>          contrib
10/22/2013  01:43 PM             6,843 hadoop-ant-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM               421 hadoop-client-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM         4,126,926 hadoop-core-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM         4,126,926 hadoop-core.jar
10/22/2013  01:43 PM           146,277 hadoop-examples-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM           146,277 hadoop-examples.jar
10/22/2013  01:43 PM               424 hadoop-minicluster-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM         2,872,189 hadoop-test-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM         2,872,189 hadoop-test.jar
10/22/2013  01:43 PM           307,933 hadoop-tools-1.1.0-SNAPSHOT.jar
10/22/2013  01:43 PM           307,933 hadoop-tools.jar
10/22/2013  01:43 PM    <DIR>          ivy
10/22/2013  01:43 PM            10,993 ivy.xml
10/22/2013  01:43 PM             6,631 Jira-Analysis.txt
01/09/2014  06:39 PM    <DIR>          lib
10/22/2013  01:43 PM    <DIR>          libexec
10/22/2013  01:43 PM            13,610 LICENSE.txt
01/15/2014  03:36 AM    <DIR>          logs
10/22/2013  01:43 PM             1,663 Monarch-CHANGES.txt
10/22/2013  01:43 PM               103 NOTICE.txt
10/22/2013  01:43 PM             2,295 README.Monarch.txt
10/22/2013  01:43 PM             1,397 README.txt
10/22/2013  01:43 PM    <DIR>          sbin
10/22/2013  01:42 PM    <DIR>          share
10/22/2013  01:43 PM    <DIR>          webapps
          21 File(s)     15,567,271 bytes
          13 Dir(s)  26,692,685,824 bytes free

请指教。

4

1 回答 1

0

Try using the following classpath:

-classpath %hadoop_home%\hadoop-core-1.1.0-SNAPSHOT.jar;%hadoop_home%\lib\commons-cli-1.2.jar

于 2014-01-16T05:31:32.087 回答