title: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
body: <p>I want to add apache cli to my application, but I have problem. These errors show when I try to run it:</p>
  
  <pre><code>Error: A JNI error has occurred, please check your installation and try again
  Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
      at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
      at java.lang.Class.getMethod0(Class.java:3018)
      at java.lang.Class.getMethod(Class.java:1784)
      at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
      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)
      ... 7 more
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>CommandLineParser parser = new PosixParser();
  Options options = new Options();
  options.addOption("a", "abc", true, "First parameter");
  
  try {
      CommandLine commandLine = parser.parse(options, args);
      System.out.println(commandLine.getOptionValue("a"));
  } catch (ParseException e1) {
      e1.printStackTrace();
  }
  </code></pre>
  
  <p>I also added in pom.xml this:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;commons-cli&lt;/groupId&gt;
      &lt;artifactId&gt;commons-cli&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>But it doesn't help :/ Also I added manually firstly commons-cli-1.3.1.jar and later commons-cli-1.2.jar but both doesn't help.</p>
  
  <p>@edit</p>
  
  <p>Ps. I'm running it as "java -jar filename.jar".</p>