Comal Rajagopalaratnam Muthukumar wrote:Hi
I have made an executable jar file through maven .Please tell me how to execute it
I tried as follows:-
mvn exec:java -D target/executablefile-name.jar
but no results
Stephan van Hulst wrote:Did you read the error message? It says exactly what's wrong.
Stephan van Hulst wrote:Can you show us your POM and Manifest?
Stephan van Hulst wrote:Why are you trying to run a WAR from the command line? A WAR is a web application, not a console application.
Your configuration looks wrong. Why do you have a <configuration> element inside a <configuration> element? Where did you get <mainClassmanifest> from? It isn't documented on the maven-war-plugin page.
Stephan van Hulst wrote:What are you trying to achieve? What are you expecting to see when the command runs successfully?
Stephan van Hulst wrote:You say executable JAR, but in your original pom you are creating a WAR. Which is it, do you want an executable jar or a web application? And if you want a web application, why are you trying to execute it from the command line, that's not what WARs are for. We explained this to you in this thread: https://coderanch.com/t/661326/tools/Maven-sharing-Jar
If you want an executable JAR, do you already know how to make one without Maven? If you do, then start out by making the simplest POM you can that can create an executable JAR that runs a Hello World program. It shouldn't contain any dependencies, and no plugins other than the ones you need to create the JAR. After that, show us what you've done. Show us the complete POM, and the complete source code of your Hello World class.
Stephan van Hulst wrote:Yes, with this POM the jar won't run, because it doesn't add a Main-Class entry to the manifest file. To do that, you need to configure the maven-jar-plugin. The applicable goal is jar:jar.
On this page, you can find the configuration options for the jar:jar goal. Use it to update your POM, so that it runs the HellowWorld class. After you're done, or when you're stuck, post your entire POM here.
Stephan van Hulst wrote:Why did you add all those children to the <archive> and <manifest> elements? Do you need them? Why are you specifying both a manifest configuration and a manifest file? Why are you running unit tests?
Get rid of the manifest file and the unit tests. This assignment is about doing the bare minimal to create an executable jar with just a POM and a hello world class.
Don't add any elements to the POM unless you need them for this assignment.
Comal Rajagopalaratnam Muthukumar wrote:the assignment you are referring is already completedin the last with the failure since
if i remove the minimal dependencies viz junittest,iam unable to compile and no jar hence is
On the other hand with the inclusion of junit test(minimal)
everything is possible but executing the jar is as usual toughest of the highest order
( I tried all means}.CAN YOU NOT A CONCRETELY EXTRACT ANY BODY from THIS FORUM WHO WAS ABLE TO not only build
jar but execut as well.Incidentally i am sure thatif maven creates a jar
only without other ejb,ear, web etc ,then he uses only one artifactId .If this inference can be
useful to you & able to activate further then please elaborate to get the needful done viz execution of jar.
Please respond to this with a yes or no since everthing was tried but the same repeatedly resulted nil.
The follwing pom.xml file is supposed to be the one that might inspire to explore especially from your
suggeted jar-plugin inclusion for your perusal Also sometimes manually plugged items do not extract the wholething frutfullyHence
the Gotchagoal might help you to help
Stephan van Hulst wrote:Why don't you show me first how you completed the POM?
Stephan van Hulst wrote:Why are you using maven-exec-plugin to run the jar? You don't need it. Run the jar like you normally would, using the java command.
Why did you add <CreatedBy>, <MainClass>, <ManifestVersion> and <Class-Path>? Are you just guessing? Did you read the jar:jar goal documentation I linked to?
Stephan van Hulst wrote:I'll repeat my questions: Are you just guessing what elements to add to the configuration, or did you read the documentation I linked to?
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!https://www.kickstarter.com/projects/paulwheaton/low-tech