Erfan Farhangy
Erfan Farhangy

Reputation: 459

How to set classpath for a maven project

I created a maven project with eclipse and made jar file from it with this below comand

mvn package

when i try to know my mvn project config is true or not with this command

mvn exec:java -D exec.mainClass="giraph.helloworld.App"

i get this error :

failed to execute goal
org.codehaus.mojo:exec-maven-plugin:1.2.1:java(default-cli) on project helloworld: An exception occured while executing the java class. null: InvocationTargetException: No arguments were provided

POM.xml setting of project is as follows. I will be so grateful if anyone can help me and specifies the reasons of this error?

  <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>giraph</groupId>   
    <artifactId>helloworld</artifactId>  
    <version>0.0.1-SNAPSHOT</version>   
    <packaging>jar</packaging>

    <name>helloworld</name>   
    <url>http://maven.apache.org</url>

    <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>            
     </properties>

    <dependencies>      
    <dependency>
        <groupId>org.apache.giraph</groupId>
        <artifactId>giraph-core</artifactId>
        <version>1.1.0</version>    
    </dependency>       
    <dependency>    
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-compiler-plugin</artifactId>  
        <version>2.0.2</version>    
    </dependency>       
   <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>1.2.1</version>
   </dependency>    
   <dependency>     
    <groupId>org.apache.maven.plugins</groupId>  
    <artifactId>maven-surefire-plugin</artifactId>  
    <version>2.10</version>
   </dependency>  
 </dependencies>
 <build> 
   <plugins>
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
        <execution>
          <goals>
            <goal>java</goal>
          </goals>
         <configuration>
           <mainClass>giraph.helloworld.App</mainClass>
         </configuration>
        </execution>
       </executions>
     </plugin>
  </plugins>
 </build> 
</project>

Upvotes: 0

Views: 10848

Answers (1)

opensam
opensam

Reputation: 368

I think the problem is that your manifest file does not contain information about the entry point (the main class) of your jar. See Setting an Application entry point.

There are many ways to rectify this problem. You can use maven assembly plugin. For more details, check here

Upvotes: 1

Related Questions