I am trying to start a jar from an Android studio. After a long workaround, the jar file works fine.
Now I need to export the jar file from Android studio. I got the Jar file from the build / libs folder.
But the problem is that the jar file shows an error.
there is no main attribute of the manifest in "app.jar"
So, I found this solution. Cannot execute jar file: "there is no main manifest attribute"
Then I read about MANIFEST.MF and added a mail class to this file.
jar {
manifest.attributes(
'Main-Class': "com.Remo.server.RemoServerApp"
)
}
After adding to my gradle. My MANIFEST.MF contains MainClass.
But am I still getting the same error? How can i solve this?
Note. The goal is that I want to export the Runnable Jar file from the project.
UPDATE:
MainClass MANIFEST.MF. .
Exception in thread "main" java.lang.NoClassDefFoundError: com/Remo/protocol/RemoConnection
at com.Remo.server.RemoServerApp.<init>(RemoServerApp.java:33)
at com.Remo.server.RemoServerApp.main(RemoServerApp.java:97)
Caused by: java.lang.ClassNotFoundException: com.Remo.protocol.RemoConnection
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
MANIFEST.MF
-: 1.0
: com.Remo.server.RemoServerApp
2
, remoprotocol jar remoserver.
remoserver gradle
apply plugin: 'java'
sourceSets {
main {
resources.srcDirs = ['src/main/resources']
}
}
dependencies {
compile project(':remoprotocol')
compile files('libs/bluecove-2.1.1.jar')
}
jar {
manifest.attributes(
'Main-Class': "com.remo.server.remoServerApp"
)
manifest.attributes(
'Class-Path': configurations.runtime.files.collect { it.getName() }.join(' '))
}
task copyRTDependenciesToLib(type: Copy) {
into "$buildDir/output/lib"
from configurations.runtime
}
gradle .