Doorgaan naar hoofdcontent

Posts

Er worden posts getoond met het label maven

Starting a main-class with maven

To run a traditional java program we have to start a main class, preferably in a JAR. However, these jars usually have dependencies, which need to be on the classpath. This leads us to two options: 1) we create a 'fat' jar, in which all are included (see one-jar, which I talked about here ) 2) when we are allowed to use maven, we can let maven create the classpath for us. In this post, I'll discuss option 2. With the maven exec:java plugin (documented here ), we can execute a main class from a specific jar. Maven then builds the classpath! For an example, we assume we have a main class in my.personal.projects.MainClass, which is hosted in the my.personal.projects.coolapp-1.0.jar, which is in the repository. It might have any number of dependencies. A sample pom.xml looks like the following:      <dependency>         <groupId>my.personal.projects</groupId>         <artifactId>coolapp<...