2014-01-15 65 views
0

在W7上安裝Haddop HDInsight之後。無法編譯具有hadoop特定實現的java程序。他們出錯誤說: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 

請指教。

+0

在哪裏Hadoop的core.jar添加? –

+0

它被列爲上述罐子之一。列表中部 – ZeExplorer

回答

0

嘗試使用下面的類路徑:

-classpath%HADOOP_HOME%\ Hadoop的核心1.1.0-SNAPSHOT.jar;%HADOOP_HOME%\ LIB \公地CLI-1.2.jar

+0

當我使用以下命令時,能夠編譯: 'javac -classpath%hadoop_home%\ hadoop-core-1.1.0-SNAPSHOT.jar;%hadoop_home%\ lib \ commons-cli-1.2。 jar C:\ Z \ WordCount.java' – ZeExplorer

+0

但無法編譯, 'java wordcount'給出ClassDefNotFound錯誤 'java -cp(與編譯相同)WordCount' 給出無法找到或加載主類。有什麼建議麼。 – ZeExplorer