1

I am trying to run a class from the maven command line but getting following error. Not sure what am I missing. Can anybody please guide?

Command

C:\my-samples\MavenCommandLine>mvn exec:java -Dexec:mainClass=com.study.maven.Main

Error-Log

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project MavenCommandLine: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java are missing or invalid -> [Help 1]

Main.java

package com.study.maven;
public class Main {  
    public static void main(String[] args) {
        System.out.println("Hello Maven!");
    }
}

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.study</groupId>
    <artifactId>MavenCommandLine</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>
</project>
Nital
  • 5,784
  • 26
  • 103
  • 195

1 Answers1

0

It's -Dexec.mainClass instead of -Dexec:mainClass (dot instead of a colon).

See the usage page.

Efthymis
  • 1,326
  • 11
  • 13
M A
  • 71,713
  • 13
  • 134
  • 174