Cannot Compile WordCount.java

2019-07-13 15:39发布

问题:

mark@maestro1:/usr/lib/hadoop/wordcount_classes$ javac -classpath /usr/lib/hadoop/hadoop-common-2.0.0-cdh4.0.1.jar:/usr/lib/hadoop/client/hadoop-mapreduce-client-core-2.0.0-cdh4.0.1.jar -d /usr/lib/hadoop/wordcount_classes /usr/lib/hadoop/wordcount_classes/WordCount.java
/usr/lib/hadoop/hadoop-common-2.0.0-cdh4.0.1.jar(org/apache/hadoop/fs/Path.class):     
warning: Cannot find annotation method 'value()' in type 'LimitedPrivate': class file for org.apache.hadoop.classification.InterfaceAudience not found
/usr/lib/hadoop/wordcount_classes/WordCount.java:14: error: error while writing Map: could not create parent directories
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
            ^
1 error
1 warning

what is with this error? I cannot compile this wordcount.java file!

People have been telling me to set my java classpath correctly. Would anyone have any comment on how I go about this as well? Please help! Thanks!

回答1:

This

-d /usr/lib/hadoop/wordcount_classes

indicates where you want the class files written. Is this correct ? I suspect you don't have permission to write there, hence:

error while writing Map: could not create parent directories

Can you create a directory in that directory (hint: use mkdir) ? I don't think the /usr/lib directory is a good place to do this, btw, even if you can. I would expect you to perform development within your home directory.

The /usr directory is usually used for installations of programs, libraries etc. and write-restricted for normal users. man hier gives a good explanation of the different directories used in Unix.