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 \
Since you've add MANIFEST.MF, I think you should consider the order of Field in this file. My env is java version "1.8.0_91"
and my MANIFEST.MF as here
// MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.8.0_91 (Oracle Corporation)
Main-Class: HelloWorldSwing
// run
~ java -jar HelloWorldSwing.jar
no main manifest attribute, in HelloWorldSwing.jar
However, this as below run through
Manifest-Version: 1.0
Main-Class: HelloWorldSwing
Created-By: 1.8.0_91 (Oracle Corporation)
//this run swing normally
(first post - so it may not be clean)
This is my fix for OS X 11.6, Maven-based Netbeans 8.2 program. Up to now my app is 100% Netbeans - no tweaking (just a few shell escapes for the impossible!).
Having tried most all of the answers here and elsewhere to no avail, I returned to the art of "use what works".
The top answer here (olivier-refalo thanx) looked like the right place to start but didn't help.
Looking at other projects which did work, I noticed some minor differences in the manifest lines:
Not sure why (I am only 3 months into java) or how, but can only say this worked.
Here is just the modified manifest block used:
<manifest>
<mainClass>mypackage.MyClass</mainClass>
</manifest>
If you are using the command line to assemble .jar it is possible to point to the main without adding Manifest file. Example:
jar cfve app.jar TheNameOfClassWithMainMethod *.class
(param "e" does that: TheNameOfClassWithMainMethod is a name of the class with the method main() and app.jar - name of executable .jar and *.class - just all classes files to assemble)
The MAVEN problem is that its try to include the first MANIFEST.MF file from first library from dependencies instead of THE OUR OWN MANIFEST.MF WHEN YOU USE ARTIFACTS!.
Copy the real MANIFEST.MF that already generate in your project by MAVEN That include somelike that:
Manifest-Version: 1.0 Main-Class: yourpacket.yourmainclass (for exmaple info.data.MainClass)
Replace the content of MANIFEST.MF from youjar.zip with it.
OR!
Simple create you own MANIFEST.MF and:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifestFile> Your path like: src/main/resources/META-INF/MANIFEST.MF </manifestFile>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
But if you use maven panel (or maven command line) you can force it to generate own manifest and include it into JAR file.
Add to the you pom.xml's build section this code:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<mainClass> yourpacket.yourmainclass (for exmaple info.data.MainClass)</mainClass>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${project.url}</url>
</manifestEntries>
</archive>
</configuration>
</plugin>
Open the MAVEN panel (in Intellij) and execute "Install". It will generate the MANIFEST file and compile property the JAR file with all dependencies into the "Target" folder. Also it will be installed to the local maven repository.
For maven, this is what solved it (for me, for a Veetle codebase on GitHub):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.lazydevs.veetle.api.VeetleAPI</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Cheers...
I had the same issue. by adding following lines to pom file made it work. The plugin will make sure the build process of your application with all necessary steps.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>