Gradle – FatJar – Could not find or load main class

I reproduced your issue locally. Just add exclude ‘META-INF/*.RSA’, ‘META-INF/*.SF’, ‘META-INF/*.DSA’ to the jar task. This will exclude the signatures of interfering dependencies. Example: jar { manifest { attributes “Main-Class”: mainClassName } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } exclude ‘META-INF/*.RSA’ exclude ‘META-INF/*.SF’ exclude ‘META-INF/*.DSA’ }

Building a self-executable JAR with Gradle and Kotlin

Add the plugin application, then set the mainClassName as mainClassName=”[your_namespace].[your_arctifact]Kt” For instance, suppose you have placed the following code in a file named main.kt: package net.mydomain.kotlinlearn import kotlin import java.util.ArrayList fun main(args: Array<String>) { println(“Hello!”) } your build.gradle should be: apply plugin: ‘kotlin’ apply plugin: ‘application’ mainClassName = “net.mydomain.kotlinlearn.MainKt” In fact Kotlin is building a … Read more

How do I create an executable fat JAR with Gradle with implementation dependencies?

You can use the following code. jar { manifest { attributes( ‘Main-Class’: ‘com.package.YourClass’ ) } from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } Be sure to replace com.package.YourClass with the fully qualified class name containing static void main( String args[] ). This will pack the runtime dependencies. Check the docs if … Read more

JDK11/JavaFX: How do I make a fat jar without build/depdency management?

This has been answered a few times already for Maven and Gradle. Build tools make things way easier than doing it on command line, and not only because of the dependency management. Since you ask specifically about command line, there is already a full set of instructions documented for it here: https://openjfx.io/openjfx-docs/#modular. Non modular App … Read more

What is an uber jar?

Über is the German word for above or over (it’s actually cognate with the English over). Hence, in this context, an uber-jar is an “over-jar”, one level up from a simple JAR (a), defined as one that contains both your package and all its dependencies in one single JAR file. The name can be thought … Read more