V
V
Vitaly the Wise2017-07-12 22:25:58
Java
Vitaly the Wise, 2017-07-12 22:25:58

How to fix Java Maven no main manifest attribute error?

Hello. I'm trying to run the project through java -jar file.jar, but I get an error no main manifest attribute. Here is my pom.xml:

<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>org.selenide.examples</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>my-app</name>
    <url>http://maven.apache.org</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.selenide.examples</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.selenide.examples.NBU</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

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

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>4.4.3</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.4.2</version>
        </dependency>
    </dependencies>
</project>

I collect through NetBeans Clean and Build. Help me please. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
magazovski, 2017-07-14
@magazovski

You probably have the wrong groupId in the plugin
Correct:
And you need to add the manifest to the classpath:

<manifest>
    <addClasspath>true</addClasspath>
    <mainClass>org.selenide.examples.NBU</mainClass>
</manifest>

maven.apache.org/shared/maven-archiver/examples/cl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question