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 \
The above answers were only partly helpful for me. java -cp
was part of the answer, but I needed more specific info on how to identify the class to run. Here is what worked for me:
Step 1: find the class I need to run
jar tf /path/to/myjar.jar | more
The top lines of the result were:
META-INF/
META-INF/MANIFEST.MF
somepath/
somepath/App.class
META-INF/maven/
...
App.class contained the main class to run. I'm not 100% sure if you can always assume the class you need is the first one, but it was for me. If it isn't, I'd imagine it isn't too hard to use grep to exclude library-related results to pare the class list down to a manageable size.
From there it was easy: I just use that path (minus the ".class" suffix):
java -cp /path/to/myjar.jar somepath/App
I had the same issue today. My problem was solved my moving META-INF to the resources folder.
I found a new solution to bad manifest generation !
Click on for META-INF
Add or edit
Add:
Create a text file called MANIFEST.MF in a folder called META-INF and add the following line:
Save the file and add it to the zip
Edit:
Open cmd and type: java -jar c:/path/JarName.jar
It should work fine now !
The Gradle answer is to add a jar/manifest/attributes setting like this:
apply plugin: 'java'
jar {
manifest {
attributes 'Main-Class': 'com.package.app.Class'
}
}
Any executable jar file Should run either by clicking or running using command prompt like java -jar app.jar (use "if path of jar contains space" - i.e. java -jar "C:\folder name\app.jar"). If your executable jar is not running, which means it is not created properly.
For better understanding, extract the jar file (or view using any tool, for windows 7-Zip is nice one) and check the file under /META-INF/MANIFEST.MF. If you find any entry like
Main-Class: your.package.name.ClaaswithMain - then it's fine, otherwise you have to provide it.
Be aware of appending Main-Class entry on MANIFEST.MF file, check where you are saving it!
If using Maven, include following in the pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>