title: Gradle : Even though jar contains main class file getting Error: Could not find or load main class
body: <p>We created jar file with all dependencies using build.gradle. It successfully gets created, with all dependencies and .class files under appropriate directory (e.g. Launch class under com.role.Browse.framework).</p>
  
  <p>But while running the jar getting Error: Could not find or load main</p>
  
  <pre><code>C:\IdeaProjects\launch_app\build\libs&gt;java -jar Launch_App-all-1.0.0.jar
  Error: Could not find or load main class com.role.Browse.framework.Launch
  </code></pre>
  
  <p>Below is the snap of <strong>build.gradle</strong></p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'maven'
  apply plugin: 'eclipse'
  
  version '1.0.0'
  
  description = ""Launch_App""
  
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  tasks.withType(JavaCompile) {
      options.encoding = 'UTF-8'
  }
  
  
  //create a single Jar with all dependencies
  
  task fatJar(type: Jar) {
      manifest {
          attributes 'Implementation-Title': 'Gradle Jar File',
                  'Implementation-Version': version,
                  'Main-Class': 'com.role.Browse.framework.Launch'
      }
      baseName = project.name + '-all'
      from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
      with jar }
  
  
  //To add this single Jar standard assemble or build task
  artifacts {
      archives fatJar
  }
  </code></pre>
  
  <p>I refer some solutions for similar issues, but nothing works for me,</p>
  
  <p><a href="https://stackoverflow.com/questions/24924932/gradle-could-not-find-or-load-main-class">Gradle : Could Not find...</a></p>
  
  <p>Note: My main class (i.e. Launch ) extends junit.framework.TestCase class and junit libraries are also included in .jar file.</p>
  
  <p>Please, let me know if anything i'm missing here.</p>