0

I wrote a test program to get familar with maven:

package com.mycompany.app;

import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;

public class App 
{
    public static void main( String[] args )
    {
        List<String> someList = new ArrayList<String>();
        CollectionUtils.addAll(someList, new String[]{ "Hello ", "World"});
        System.out.println( someList.get(0)+someList.get(1) );
    }
}

And I added the commons-collections dependency to the pom.xml:

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>

I was able to compile it with

mvn clean package

How do I execute it? I could find me the correct version of the commons-collection library and could run it by explicit mentioning it at the start, but at least the finding the correct version is job of maven.

If I want to give it to someone who doesn't has maven, what do I do?

I would expect there is a command that collects all dependent jars and put it in a folder.

Tim
  • 101
  • 2
  • If you want to offer someone else the code I would suggest to create a github repo which someone else clone. But that means to build it you have to use the defined tools that includes Maven in such case.. What I don't understand is: `but at least the finding the correct version is job of maven.` ? Can you clear that up? – khmarbaise Sep 23 '21 at 16:22
  • Maven downloads the commons-collections.3.2.2.jar (or however it is called) somewhere into the .m2 folder. That folder has a lot of jars and finding that one jar in that folder is work that maven can do better than me. Maven also knows the dependencies of commons-collections.3.2.2.jar and I don't. So maven can find the correct version of the jars and I don't. – Tim Sep 24 '21 at 07:57
  • Maven uses the version of jars you have defined in your project nothing else – khmarbaise Sep 24 '21 at 09:54
  • And the jars that those jars need and the jars that those jars need and ... – Tim Oct 01 '21 at 07:09

0 Answers0