Suppose that we have a Java application, rather than a library, which is available through Maven central. For example, one such project is jol, which has its corresponding CLI interface in Maven central.
As far as I can tell, the main difference from a library is that the corresponding JAR file contains a class with an appropriate main()
method and, optionally, a related Main-Class:
header in the JAR manifest. If such an artifact is used as a dependency on a project, Maven will happily download the JAR file to the local repository along with its dependencies, as it does for any other artifact.
Is it possible to use Maven to execute such an application directly, without setting up a Maven project?
The exec:java
plugin works nicely for local projects by setting up the JVM classpath so that dependencies are available. The user does not have to worry about JAR or .class
file locations and such. Unfortunately, from what I can tell, it also requires an enclosing Maven project, so it cannot be used from an arbitrary command line prompt.
exec:java
, for example, will set up the JVM classpath so that dependencies are available. That is what I am after... – Presber