I have created a Netbeans Gradle project, and I am trying to find the best way to export this to a .jar file so that it can be opened from outside the IDE. I am using dependencies within my project, and I was receiving a java.lang.NoClassDefFoundError.
To resolve this, I tried adding
jar {
manifest {
attributes "Main-Class": "CollegeCounselor.Main"
}
from{
configurations.compile.collect{ it.isDirectory() ? it : zipTree(it)}
}
}
to my build.gradle file. However, this threw a java.lang.SecurityException: Invalid signature file digest for Manifest main attributes.
To fix this, I found a suggestion to add
{exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'}
to my file. This fixes the issue of running the file through the command line. Running it through java -jar
works now. However, I still cannot run it through the finder on my mac. It gives me an error saying the java jar could not be launched and tells me to check the console for more details. I am unable to understand how to fix the issue, or why I can run it through the command line but not through the finder window. I am going to the build/libs/file.jar path and attempting to open this file.
Any assistance regarding the best way to export this project would be greatly appreciated.
Here is my full build.gradle file:
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'application'
mainClassName = 'CollegeCounselor.Main'
repositories {
jcenter()
}
dependencies {
testCompile 'junit:junit:4.12'
compile('com.microsoft.graph:microsoft-graph:1.5.+')
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.4.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
}
jar {
manifest {
attributes "Main-Class": "CollegeCounselor.Main"
}
from { (configurations.runtime).collect { it.isDirectory() ? it : zipTree(it) } }
{
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
}
}