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 \
You Can Simply follow this step Create a jar file using
jar -cfm jarfile-name manifest-filename Class-file name
While running the jar file simple run like this
java -cp jarfile-name main-classname
Alternatively, you can use maven-assembly-plugin, as shown in the below example:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.package.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
In this example all the dependency jars as specified in section will be automatically included in your single jar. Note that jar-with-dependencies should be literally put as, not to be replaced with the jar file names you want to include.
I had this problem and i solved it recently by doing this in Netbeans 8 (Refer to the image below):
I got same error just now.
If u're using gradle
, just add next one in ur gradle.build
:
apply plugin: 'java'
jar {
manifest {
attributes 'Main-Class': 'com.company.project.MainClass'
}
}
Where com.company.project.MainClass
path to ur class with public static void main(String[] args)
method.
I had this issue when creating a jar using IntelliJ IDEA. See this discussion.
What solved it for me was to re-create the jar artifact, choosing JAR > From modules with dependencies, but not accepting the default Directory for META-INF/MANIFEST.MF. Change it from -/src/main/java to -/src/main/resources.
Otherwise it was including a manifest file in the jar, but not the one in -/src/main/java that it should have.
Try this command to include the jar:
java -cp yourJarName.jar your.package..your.MainClass