I’ve created simple java program (maven with pom ) which when I run some command with CMD it should created a file under given path... I do mvn clean install
which finish successfully,
Now I want to use this created jar from the command line like follwoing:
java -jar "/Users/i012/IdeaProjects/myproj/target/test.rts-1.0-SNAPSHOT.jar" path2genfile2create
Which should run my program (this the first time that I try something like this…)
But the error which Im getting is:
no main manifest attribute, in /Users/i012/IdeaProjects/myproj/target/test.rts-1.0-SNAPSHOT.jar
What could be missing here ? which manifest attribute ?
The error is not coming from the class i’ve created …
i've created some META-INF/MANIFEST.MF not helping but maybe Its wrong
For a JAR file to run, the JAR itself must contain at least one class that has a runnable main method. Furthermore, the class with the main method must be listed as the main-class in the JAR's manifest file. If not, the class must be explicitly stated on the command line when the JAR is run.
The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.
If you're using the Maven assembly plug-in, or your IDE tooling is, you need a mainClass
element. This is what I use:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.foo.MyMainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With