hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris MacKenzie <stu...@chrismackenziephotography.co.uk>
Subject Re: Cannot compaile a basic PutMerge.java program
Date Mon, 28 Jul 2014 09:17:25 GMT

I can probably help you out with that. I donĀ¹t want to sound patronising
though. What is your IDE and have you included the hadoop libraries in
your jar ?



Chris MacKenzie
telephone: 0131 332 6967
email: studio@chrismackenziephotography.co.uk
corporate: www.chrismackenziephotography.co.uk

From:  R J <rj201244@yahoo.com>
Reply-To:  <user@hadoop.apache.org>
Date:  Monday, 28 July 2014 01:46
To:  "user@hadoop.apache.org" <user@hadoop.apache.org>
Subject:  Cannot compaile a basic PutMerge.java program

Hi All,

I am new to programming on hadoop. I tried to compile the following
program (example program from a hadoop book) on my linix server where I
have Haddop installed:
I get the errors:
$javac PutMerge.java
PutMerge.java:2: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.Configuration;
PutMerge.java:3: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FSDataInputStream;
PutMerge.java:4: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FSDataOutputStream;
PutMerge.java:5: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FileStatus;
PutMerge.java:6: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.FileSystem;
PutMerge.java:7: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;

I have $HADOOP_HOME set u:

Could you please suggest how to compile this program? Thanks a lot.



import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class PutMerge {

public static void main(String[] args) throws IOException {
Configuration conf = new Configuration();
FileSystem hdfs = FileSystem.get(conf);
FileSystem local = FileSystem.getLocal(conf);

Path inputDir = new Path(args[0]);
Path hdfsFile = new Path(args[1]);

try {
FileStatus[] inputFiles =
FSDataOutputStream out = hdfs.create(hdfsFile);

for (int i=0; i<inputFiles.length; i++) {
FSDataInputStream in = local.open(inputFiles[i].getPath());
byte buffer[] = new byte[256];
int bytesRead = 0;
while( (bytesRead = in.read(buffer)) > 0) {
out.write(buffer, 0, bytesRead);
} catch (IOException e) {


View raw message