title: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext maven
body: <p>I am new to spring and maven. I have a simple hello world project using Spring . The project builds successfully but i face the following error at runtime: </p>
  
  <pre><code>Error: A JNI error has occurred, please check your installation and try again
  Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
  </code></pre>
  
  <p>This is the main app: App.java </p>
  
  <pre><code>package com.test.SpringMaven2;
  
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.annotation.AnnotationConfigApplicationContext;
  
  
  
  /**
   * Hello world!
   *
   */
  public class App 
  {
      public static void main( String[] args )
      {
          System.out.println( "Hello World!" );
          System.out.println( "Hello World!" );
          ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfig.class);
  
          HelloWorld hello = (HelloWorld) context.getBean("helloWorld"); 
          hello.setName("Adnan");
          hello.getName();
      }
  }
  </code></pre>
  
  <p>This is the HelloWorld bean </p>
  
  <pre><code>package com.test.SpringMaven2;
  
  public class HelloWorld{
  
  
      private String name; 
  
      public void setName(String name){
          this.name = name;
      }
  
      public void getName(){
          System.out.println("Hello, " + name);
      }
  }
  </code></pre>
  
  <p>This is the annotation based configuration file: </p>
  
  <pre><code>package com.test.SpringMaven2;
  
  
  import org.springframework.context.annotation.*;
  
  @Configuration
  public class HelloWorldConfig{
  
      @Bean
      public HelloWorld helloWorld(){
          return new HelloWorld(); 
      }
  
  }
  </code></pre>
  
  <p>This is my pom.xml </p>
  
  <pre><code>&lt;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"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;com.test&lt;/groupId&gt;
    &lt;artifactId&gt;SpringMaven2&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;name&gt;SpringMaven2&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
              &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
   &lt;groupId&gt;org.springframework&lt;/groupId&gt;
   &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
   &lt;version&gt;4.3.3.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I am running the following command in CMD to run the application: 
  java -cp {nameofresultjarfile} com.test.SpringMaven2.App</p>
  
  <p>But getting the error messsage above </p>
  
  <p>Any advice? </p>
  
  <p>Thanks</p>