What is MOP?
MOP is a small utility for executing Java programs which are stored as artifacts like jars or bundles in a Maven repository.
MOP automatically deals with the following for you
- transitive dependencies
- downloading artifacts from remote repositories and caching them locally
- setting up your classpath
First download and install mop then you can run it from the command line as follows
This will then output the command line help to show the command line arguments you can use.
If you are inside the download directory (or you copy the mop.jar to your current directory) then you can just execute the jar directly instead of running the mop script as follows
java -jar mop.jar
Running Java programs
mop run org.apache.camel:camel-example-pojo-messaging org.apache.camel.spring.Main
The run command takes a maven artifact name then a Java class name along with optional command line arguments. The maven artifact uses the following format
The above will startup MOP in a JVM and then start the Main inside the same JVM in a separate class loader. If you want MOP to fork a separate JVM process then switch the run command with exec as follows
mop exec org.apache.camel:camel-example-pojo-messaging org.apache.camel.spring.Main
If the jar is an executable jar so that its Jar manifest has a Main-Class entry, then you can use the jar command instead which allows you to omit the Java class name as follows
mop jar org.apache.camel:camel-example-pojo-messaging
Running Web Applications
If you have a WAR in a repository somewhere you can run it via
mop war <artifacts>
For example if you want to run the ActiveMQ Web console and broker you can run the following
mop war org.apache.activemq:activemq-web-console:5.2.0
Though there is a simple alias to let you run Apache ActiveMQ
Sometimes, you just want to see what command line you need to type in to run the Main. Try this
mop echo org.apache.camel:camel-example-pojo-messaging org.apache.camel.spring.Main
Other times, you just need need the CLASSPATH so you can use it in a manually crafted script your running. Try this.
mop classpath org.apache.camel:camel-example-pojo-messaging
Or maybe you just want to copy all those jars in the classpath to directory, perhaps your trying to populate a `WEB-INF/lib` directory.
mop copy org.apache.camel:camel-example-pojo-messaging WEB-INF/lib