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
If you're using the Maven assembly plug-in, or your IDE tooling is, you need a
mainClass
element. This is what I use:You need a main class to execute you application. Try the following. It worked for me.
Add the following code snippet to your pom.xml file if you are using maven build tool.
A manifest is a file in the path META-INF/MANIFEST.MF within the jar which defines attributes like the classpath and the main class for running the jar file.
The basic structure would be like:
You can define your entry point by adding the property
Main-Class: classname
.In order to create your jar file with a given manifest you can:
jar cfm MyJar.jar Manifest.txt MyPackage/*.class
to manually create a jar with the given manifest and classes.You can find out more about the jar manifest file here.
in my case, I was using spring-boot but i did not mentioned my builder in my pom so i fixed it by: