0

I have java code and pom.xml and want to create a runnable jar file. java code:

package table;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.*;
public class insert {
    public static void main(String[] args) throws IOException{
       ....
    }
 }

And for the pom.xml file:

<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>apache.hbase</groupId>
<artifactId>hbaseTable</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
        <name>hbaseTable</name>
        <url>http://maven.apache.org</url>

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

<dependencies>
        <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
        </dependency>
        <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-server</artifactId>
                <version>1.1.1</version>
        </dependency>
        <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-testing-util</artifactId>
                <version>1.1.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>apache.hbase.insert</mainClass>
                </configuration>
            </plugin>
            <!-- <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-assembly-plugin</artifactId>
              <configuration>
                    <archive>
                    <manifest>
                        <mainClass>table.insert</mainClass>
                    </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
              </configuration>
            </plugin> -->
        </plugins>
    </build>

and then I use mvm compile, mvm package to get a jar file, but when i run it, its always : no main manifest attribute or can not load or find class:table.insert . how can i config the pom.xml file especially for the main class part. I run it use java -jar /path/to/jar. Thanks, i am new to maven and already tried Can't execute jar- file: "no main manifest attribute"

Community
  • 1
  • 1
printemp
  • 869
  • 1
  • 10
  • 33
  • It will not help you with your issue but general naming convention requires that class names start with a capitalized letter: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#15411 – StephaneM Sep 04 '15 at 08:08
  • Try this --> http://stackoverflow.com/questions/27040896/maven-jar-with-classpath-in-manifest/27041332#27041332 and tell me if it helps – Iker Aguayo Sep 04 '15 at 08:26
  • Post the complete stack trace of the exception. What is probably missing is the classpath, so that classes on which your class depends can be found. – JB Nizet Sep 04 '15 at 08:33
  • @JBNizet. sorry just when mvm package, build succeed. java -jar hbaseTable-0.0.1-SNAPSHOT-jar-with-dependencies.jar Error: Could not find or load main class apache.hbase.insert – printemp Sep 04 '15 at 08:54

0 Answers0