title: Gradle, error could not find or load main class 'test.Main'
body: <p>I implemented Gradle on <a href="https://github.com/elect86/jgli" rel="nofollow noreferrer">one</a> of my projects. I use Netbeans 8.02 with the gradle plugin.</p>
  
  <p>Structure is as it should be, sources are located under <code>jgli/src/main/java/</code>, resources under <code>jgli/src/main/resources/</code></p>
  
  <p>The Main class is <code>jgli/src/main/java/test/Main.java</code></p>
  
  <p>If I run it through the ide, it runs on windows, it <a href="https://stackoverflow.com/questions/33195461/netbeans-gradle-and-jogl-crash/33236797#33236797">crashes</a> on linux. That's why I am trying to run it through the console right now:</p>
  
  <p><code>java -jar jgli.jar</code></p>
  
  <p>But I keep getting:</p>
  
  <blockquote>
    <p>Error could not find or load main class 'test.Main'</p>
  </blockquote>
  
  <p>This is my <code>build.gradle</code></p>
  
  <pre><code>apply plugin: 'java'
  
  sourceCompatibility = '1.8'
  [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  
  // NetBeans will automatically add "run" and "debug" tasks relying on the
  // "mainClass" property. You may however define the property prior executing
  // tasks by passing a "-PmainClass=&lt;QUALIFIED_CLASS_NAME&gt;" argument.
  //
  // Note however, that you may define your own "run" and "debug" task if you
  // prefer. In this case NetBeans will not add these tasks but you may rely on
  // your own implementation.
  if (!hasProperty('mainClass')) {
      ext.mainClass = ''
  }
  
  repositories {
      mavenCentral()
      // You may define additional repositories, or even remove "mavenCentral()".
      // Read more about repositories here:
      //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
  }
  
  dependencies {
      // TODO: Add dependencies here ...
      // You can read more about how to add dependency here:
      //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
      testCompile group: 'junit', name: 'junit', version: '4.10'
  
      compile 'org.jogamp.jogl:jogl-all-main:2.3.2'
      compile 'org.jogamp.jogl:nativewindow-main:2.3.2'
      compile 'org.jogamp.jogl:newt-main:2.3.2'
      compile 'org.jogamp.gluegen:gluegen-rt-main:2.3.2'
  }
  
  jar {
      manifest {
          attributes 'Main-Class': 'test.Main'
      }
  }
  </code></pre>
  
  <p>I just modified the <code>dependecies</code> section and added the manifest part.</p>
  
  <p>I tried to add <code>'test.Main'</code> to the ext.mainClass, but it changed nothing..</p>
  
  <p><a href="https://www.wetransfer.com/downloads/c731bf8e972241c7b73f9c43a616646a20151022075125/8ceeb7acf90bb54d62ad243d086dc22920151022075125/7cce94" rel="nofollow noreferrer">Here</a> you can download the jar.</p>
  
  <p>This is my <code>MANIFEST.MF</code>:</p>
  
  <pre><code>Manifest-Version: 1.0
  Main-Class: test.Main
  </code></pre>
  
  <p>Main.class is properly located inside the jar.
  Main.java has the package declaration <code>package test;</code></p>
  
  <p>Tried also</p>
  
  <pre><code>apply plugin: 'application'
  
  mainClassName = 'test.Main'
  </code></pre>
  
  <p>without success..</p>
  
  <p>What am I missing?</p>