title: Error displaying files in Hadoop filesystem on standard output using FileSystem directly
body: <p>I'm new to Hadoop and was trying to display file contents in Hadoop filesystem on standard output using the FileSystem directly but am getting the below error. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import java.io.InputStream;
  import java.net.URI;
  
  import org.apache.hadoop.conf.Configuration;
  import org.apache.hadoop.fs.FileSystem;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.io.IOUtils;
  
  
  public class FileSystemCat {
  
    public static void main(String[] args) throws Exception {
     Configuration conf = new Configuration();
        conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/core-site.xml"));
        conf.addResource(new Path("/usr/local/hadoop/etc/hadoop/hdfs-site.xml"));
      String uri = "/books/pg5000.txt";
    FileSystem fs = FileSystem.get(URI.create(uri), conf);
    InputStream in = null;
    try {
     in = fs.open(new Path(uri));
     IOUtils.copyBytes(in, System.out, 4096, false);
     } finally {
     IOUtils.closeStream(in);
     }
    }
  }
   
   </code></pre>
  </div>
  </div>
  </p>
  
  <p>Error - </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
      at org.apache.hadoop.security.authentication.util.KerberosName.&lt;clinit&gt;(KerberosName.java:43)
      at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:261)
      at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:248)
      at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:763)
      at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:748)
      at 
  
      org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:621)
          at org.apache.hadoop.fs.FileSystem$Cache$Key.&lt;init&gt;(FileSystem.java:2753)
          at org.apache.hadoop.fs.FileSystem$Cache$Key.&lt;init&gt;(FileSystem.java:2745)
          at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2611)
          at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:370)
          at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:169)
          at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:354)
          at FileSystemCat.main(FileSystemCat.java:17)
      Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
          ... 13 more
  </code></pre>
  
  <p>Can someone guide me, where am I wrong?</p>