Gradle and Maven compile my project but I am getting NoClassFoundError <p>I am trying to compile my project which uses Gradle and Maven. The project use another library on my local maven repository. The library is referenced in Gradle and Maven:</p> <p>Gradle:</p> <pre><code>dependencies{ compile 'cf.charly1811.java.utils:MimeType:1.0' } </code></pre> <p>Maven:</p> <pre class="lang-xml prettyprint-override"><code>&lt;!-- Dependencies --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;cf.charly1811.java.utils&lt;/groupId&gt; &lt;artifactId&gt;MimeType&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre> <p>When I try compile the project using <code>mvn clean package</code> or <code>gradle clean jar</code> it success. The error arises when the MimeType class is called:</p> <pre><code> Exception in thread "Thread-4" java.lang.NoClassDefFoundError: cf/charly1811/java/utils/MimeType at cf.charly1811.java.web.RequestHandlerThread.process(RequestHandlerThread.java:120) at cf.charly1811.java.web.RequestHandlerThread.handleRequest(RequestHandlerThread.java:85) at cf.charly1811.java.web.RequestHandlerThread.run(RequestHandlerThread.java:64) Caused by: java.lang.ClassNotFoundException: cf.charly1811.java.utils.MimeType at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 3 more </code></pre> <p>I don't know what causing this error... Please help.</p> <p>EDIT: MimeType pom.xml: </p> <pre class="lang-xml prettyprint-override"><code>&lt;project&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;name&gt;MimeType&lt;/name&gt; &lt;description&gt;Library to easily get the type of a file&lt;/description&gt; &lt;groupId&gt;cf.charly1811.java.utils&lt;/groupId&gt; &lt;artifactId&gt;MimeType&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;licenses&gt; &lt;license&gt; &lt;name&gt;Apache License, Version 2.0&lt;/name&gt; &lt;url&gt;http://www.apache.org/licenses/LICENSE-2.0.txt&lt;/url&gt; &lt;distribution&gt;repo&lt;/distribution&gt; &lt;comments&gt;A business-friendly OSS license&lt;/comments&gt; &lt;/license&gt; &lt;/licenses&gt; &lt;/project&gt; </code></pre> <p>HttpServer (Main project) pom.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;project&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;name&gt;HttpServer&lt;/name&gt; &lt;description&gt;A simple HTTP Server written in JAVA&lt;/description&gt; &lt;groupId&gt;cf.charly1811.java.web&lt;/groupId&gt; &lt;artifactId&gt;HttpServer&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;!-- Dependencies --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;cf.charly1811.java.utils&lt;/groupId&gt; &lt;artifactId&gt;MimeType&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;!-- License --&gt; &lt;licenses&gt; &lt;license&gt; &lt;name&gt;Private use&lt;/name&gt; &lt;url&gt;http://choosealicense.com/licenses/no-license/&lt;/url&gt; &lt;comments&gt;This Software is for private use Only&lt;/comments&gt; &lt;/license&gt; &lt;/licenses&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;mainClass&gt;cf.charly1811.java.Main&lt;/mainClass&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>EDIT I forgot to clarify 1 thing: I use IntelliJ IDEA. When I try to compile the project using "Run" It compile everything and I don't get this error. It only happen when I use Gradle or Maven to compile the project</p>