title: error while running maven project java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils
body: <p>I created a maven project and add a dependency apache commons-io in pom.xml
  file.</p>
  <pre class="lang-maven prettyprint-override"><code>    &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  <p>I added dependency common-io so I can use commons.io.IOUtils in my project in order to read the file from the resource folder.
  <code>/src/main/resources/file/file.txt</code>.</p>
  <p>Everything works during compiling and packaging but when I run the jar</p>
  <p>java -cp target/maven-1.0-SNAPSHOT.jar com.sample.exercise.Main</p>
  <p>I'm getting this error</p>
  <pre><code>       Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils
              at com.sample.exercise.Main.getFileWithUtil(Main.java:21)
              at com.sample.exercise.Main.main(Main.java:13)
          Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils
              at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
              ... 2 more
  </code></pre>
  <p>Here's my code</p>
  <pre class="lang-java prettyprint-override"><code>    package com.sample.exercise;
  
          import java.io.*;
          import java.util.*;
          import org.apache.commons.io.IOUtils;
  
          public class Main{
  
            public static void main(String[] args) {
                Main main = new Main();
                System.out.println(main.getFile(&quot;file/fileTable.txt&quot;));
          
            } 
      
            private String getFileString fileName) {
                String result = &quot;&quot;;
                ClassLoader classLoader = getClass().getClassLoader();
                try {
                  result =IOUtils.toString(classLoader.getResourceAsStream(fileName));
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return result;
             }
      }
  </code></pre>
  <p>What is the problem. can you help me with this? TIA</p>