V
V
Virgil Merkel2019-03-20 22:29:41
Java
Virgil Merkel, 2019-03-20 22:29:41

It gives no main manifest attribute, in project.jar, how can I fix this?

I'm trying to build a project using maven, I get an error no main manifest attribute, in first_project.jar.
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>first_project</groupId>
    <artifactId>first_project</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>firstProject</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>deleveryClub.MainApp</mainClass>
    </properties>

    <organization>
        <!-- Used as the 'Vendor' for JNLP generation -->
        <name>Your Organisation</name>
    </organization>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>12</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-base -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>11.0.1</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-graphics -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>11</version>
        </dependency>



    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>deleveryClub.MainApp</mainClass>
                </configuration>
            </plugin>

            <plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>deleveryClub.MainApp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

project link: https://github.com/CptWasp/vk-tester-selenium

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2019-03-20
@blrmyfc

Hello!
Please tell me which IDE you are building the project with? If Intellij IDEA, then this problem is already familiar to me ...
I stumbled upon it more than once ... In general, when you build a jar, then for some reason intellij idea, if you select create jar from modules & dependencies, it creates the jar incorrectly. This problem is relevant to the latest version. And accordingly, the META-INF folder does not get into the jar AND the MANIFEST.MF file
To exclude this, create jar - empty
The error itself says that you do not have the above file and folder in the jar file. Then it will work correctly.
Also if it's maven || gradle, then put the meta-inf folder at the project level, or in the resources folder. Not in java!
Here, here is my answer on this issue (with a screenshot) -https://stackoverflow.com/questions/1082580/how-to...

O
OldViper, 2019-12-07
@OldViper

Actually! For information: when manually building a JAR, from cmd with the line:
...>javac -cp ".;test.jar" prog.java , the
JAR is then launched in cmd with this line: ....>java -cp ".; test.jar" prog
If you type the command: ....>java -jar test.jar , then it will not start, AND SHOULD NOT!
cmd will give the same result - no main manifest attribute, although if you unzip the JAR, the manifest file IS IN IT!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question