I'm trying to setting up a call to HDFS to get a file from it using FileSystem to do so:
FileSystem fs = new FileSystem.get(new URI.create(uri), conf);
But I getting this two errors even so I called all the libraries
Error:(46, 39) java: cannot find symbol symbol: class get location: class org.apache.hadoop.fs.FileSystemError:(46, 47) java: cannot find symbol symbol: method create(java.lang.String) location: class org.apache.commons.httpclient.URI
This is for hadoop 2.7.7 version. I already tried imported the hole library org.apache.hadoop.fs.;but still the method get and create is not there when I’m trying to use them in the line as follow: FileSystem fs = new FileSystem.get(URI.create(usi), conf)
import org.apache.commons.httpclient.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;public class Test {
public static void main(String []args) {String uri = "hdfs://localhost:9000/data.json"; Configuration conf = new Configuration(); //cannot find symbol get //Cannot find symbol create FileSystem fs = new FileSystem.get(new URI.create(uri), conf); InputStream in = null; try { in = fs.open(new Path(uri)); IOUtils.copyBytes(in, System.out, 4096, false); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeStream(in); }
}
}
And here is my POM.xml file:
<?xml version=“1.0” encoding=“UTF-8”?>
<project xmlns=“http://maven.apache.org/POM/4.0.0”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion><groupId>com.boeing.bedl</groupId>
<artifactId>IngestionData</artifactId>
<version>1.0-SNAPSHOT</version><dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.7.7</version>
</dependency><dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-yarn-common</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-mapreduce-client-core</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-mapreduce-client-common</artifactId> <version>2.7.7</version> </dependency>
</dependencies>
</project>
#java #maven #hadoop