Hadoop Library is imported but cannot set the “get” method in FyleSystem

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.FileSystem
Error:(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>

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
    &lt;artifactId&gt;hadoop-yarn-common&lt;/artifactId&gt;
    &lt;version&gt;2.7.7&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
    &lt;artifactId&gt;hadoop-mapreduce-client-core&lt;/artifactId&gt;
    &lt;version&gt;2.7.7&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
    &lt;artifactId&gt;hadoop-mapreduce-client-common&lt;/artifactId&gt;
    &lt;version&gt;2.7.7&lt;/version&gt;
&lt;/dependency&gt;

</dependencies>
</project>


#java #maven #hadoop

4 Likes2.35 GEEK