I have installed an application, when I try to run it (it\'s an executable jar) nothing happens. When I run it from the commandline with:
java -jar \
First, it's kind of weird, to see you run java -jar "app"
and not java -jar app.jar
Second, to make a jar executable... you need to jar a file called META-INF/MANIFEST.MF
the file itself should have (at least) this one liner:
Main-Class: com.mypackage.MyClass
Where com.mypackage.MyClass
is the class holding the public static void main(String[] args) entry point.
Note that there are several ways to get this done either with the CLI, Maven, Ant or Gradle:
For CLI, the following command will do: (tks @dvvrt)
jar cmvf META-INF/MANIFEST.MF .jar
For Maven, something like the following snippet should do the trick. Note that this is only the plugin definition, not the full pom.xml:
org.apache.maven.plugins
maven-jar-plugin
3.1.0
true
lib/
com.mypackage.MyClass
(Pick a
For Ant, the snippet below should help:
Credits Michael Niemand -
For Gradle:
plugins {
id 'java'
}
jar {
manifest {
attributes(
'Main-Class': 'com.mypackage.MyClass'
)
}
}