Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Fwd: m2eclipse & bundling up selenium dependencies


You will in any case need to add supplementary jar dependencies to your command line.

The easiest way is to use the maven plugin dependency and execute its copy-dependencies [] at package phase.

You can do it by adding that plugin configuration:


This would automatically copy the needed jar files in target/dependencies so that you can adapt java -cp target/<NameOfJar>;taget/dependencies/* VxcExperience.Selenium.Example.SeleniumDemoTests.RemoteWebDriverTest

I also seen people using unpack goal to unzip all dependencies jar in a folder in a previous phase so that package phase will create one huge single jar file but it is very discouraged.

2012/5/15 Bhréin Brannick <bhreinb@xxxxxxxxx>

I hoping someone on this mailer can help with the following. I'm a newbie to Eclipse & Maven and this may be a basic question but I'm trying to build a single executable Jar file that will include project dependencies so for this I'm using m2eclipse a maven plugin for eclipse. So here is where I'm at present.

The project has two main java files and one test file (default test and main file through using m2eclipse new project wizard). I added my own class namely the following

package VxcExperience.Selenium.Example.SeleniumDemoTests;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class RemoteWebDriverTest
    public static void main(String[] args) throws Exception
        WebDriver driver = new RemoteWebDriver(new URL(""), DesiredCapabilities.firefox());

            driver.manage().window().setPosition(new Point(100, 100));
             driver.manage().window().setSize(new Dimension(600, 600));

As you can see per the above this class would have dependency on Selenium packages which I used m2eclipse to resolve and am able to run as a Java application within the IDE. Namely all the selenium libraries are located under Maven Dependencies within package explorer. So far OK. But what I'm trying to do is export it to a single Jar file that would have references to selenium dependencies within it so that i can essentially drop on another users machine and run like the following from a command line:

java -classpath <NameOfJar>.jar VxcExperience.Selenium.Example.SeleniumDemoTests.RemoteWebDriverTest

However, this never works as the built jar doesn't include the Selenium references from viewing the package using 7-zip. But if i tried the sample that is created using the wizard for example

java -classpath <NameOfJar>.jar VxcExperience.Selenium.Example.SeleniumDemoTests.App

it prints hello world. I wonder what I'm trying to do is achievable using eclipse and m2eclipse or am I missing a step? I believe m2eclipse to be the tool to use to bundle up dependencies into a runnable single jar file. Sorry to spam the wrong mailer if this is not the right place to ask this question but I'd appreciate any guidance given. Thanks in advance. Btw my pom.xml looks like the following

<project xmlns="" xmlns:xsi=""







Kind Regards,


m2e-users mailing list


Eric Cornely
Trainer @ Vision IT Group
Chaussée de Louvain 431 (Bât H)
1380 Lasne
Mobile : +32 (0)494 25 22 77

Please consider the environment before printing this e-mail

Back to the top