title: Gradle - FatJar - Could not find or load main class
body: <p>I know that question was asked a lot and has many answers, but i still get it and I don't understand why...</p>
  
  <p>I am trying to generate a <code>.jar</code> from a projet with dependencies with gradle.</p>
  
  <p>I have a class <code>src/main/java/Launcher.java</code>, in which I have my <code>main</code> method.</p>
  
  <p>there is my <code>build.gradle</code></p>
  
  <pre><code>plugins {
      id 'java'
      id 'application'
  }
  
  version '1.0-SNAPSHOT'
  sourceCompatibility = 1.8
  mainClassName = 'Launcher'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile 'commons-io:commons-io:2.1'
      compile 'io.vertx:vertx-core:3.4.0'
      compile 'io.vertx:vertx-web:3.4.0'
      compile 'com.google.code.gson:gson:1.7.2'
      compile "com.auth0:java-jwt:3.1.0"
      compile 'org.mongodb:mongo-java-driver:3.4.1'
      compile 'com.google.guava:guava:24.1-jre'
      compile 'commons-io:commons-io:2.6'
  }
  
  jar {
      manifest {
          attributes "Main-Class": mainClassName
      }
  
      from {
          configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
      }
  }
  </code></pre>
  
  <p>I use <code>$&gt;gradle assemble</code> to generate my jar
  then <code>$&gt;java -jar path/to/my/.jar</code>
  And i get the error "could not find or load main class Launcher"...</p>
  
  <p>I dont understand why, when I look in the .jar, I have Launcher class and in META-INF I have my manifest</p>
  
  <p><a href="https://i.stack.imgur.com/kblqu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kblqu.png" alt="screenshot"></a></p>
  
  <p>Sorry for still asking this question in 2018 but i'm loosing my mind trying to figure out what's wrong. I hope somone will have the answer !</p>