简体   繁体   中英

No main manifest attribute - IntelliJ

I know there have been many posts on this but I can't seem to find an appropriate solution. So I have my 3 classes, one with a main and from IntelliJ everything runs fine. But I cannot seem to run the .jar file that I have created.

I also have a manifest file that contains the following:

Manifest-Version: 1.0
Main-Class: beanParser

I created the jar through the build option in IntelliJ. Any suggestions?

Thanks

MANIFEST.MF should be in:

src/main/resources/META_INF/

NOT in:

src/main/java/META_INF/

Have you considered the following link ?

For Maven have a look at the following clip or this one .

Here's a snipped I used in my project:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>your.main.Clazz</mainClass>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.directory}/lib/
                        </outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM