I want to make a jar file of my project but it shows error when I try to make jar.
Till now, I build a jar that is executed by using a command ,
java -cp <JAR FILE> <MAIN CLASS NAME>
.
I have done this by adding plugin in the POM,
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
and by running command , mvn clean
and mvn install assembly:assembly
.
But I want a jar, that will run by using command java -jar <JAR FILE>
For that I read this link and implemented also. But it shows below error,
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar) on project ThreadPool: Unable to parse configuration of mojo org.apache.maven.plugins:maven-jar-plugin:2.4:jar for parameter manifest: Cannot find setter, adder nor field in org.apache.maven.archiver.ManifestConfiguration for 'addClassPath' -> [Help 1]
Please help me making jar file, that executes by using java -jar
command.
Thanks in advance . Looking for your kind response.
EDIT NO 1
I added below plugins, dependency in POM,
<!-- Example dependency -->
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>