I am trying to run java application built in Maven 2 from command prompt
On command prompt I did “mvn package” and got the jar in target folder of the application
Then I did:-
java -cp target/TempestApp.jar foo.App
And I get exception:-
Exception in thread "main" java.lang.NoclassDefFoundError: org/w3c/tidy/Tidy
at foo.htmltoxml.HtmlToXMLConvertor(htmltoxml.java:29)
at foo.app.main(App.java:35)
The application comprises of a JTidy. Who’s dependency is mention in the POM.xml
Application runs fine in Eclipse but not from command prompt.
I even tried putting the JTidy jar in classpath variable
You can let maven start your application with all the jars in the classpath. It is quite easy with the
exec-maven-plugin.Add this into your
pom.xml:Then when you want to build and execute in the same command:
And if you just want to run the application: