5

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

joey7492
  • 117
  • 3
  • 3
  • 12

2 Answers2

10

MANIFEST.MF should be in:

src/main/resources/META_INF/

NOT in:

src/main/java/META_INF/

Vlad
  • 1,541
  • 1
  • 21
  • 27
5

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>
kenorb
  • 155,785
  • 88
  • 678
  • 743
Ronald Duck
  • 323
  • 1
  • 11
  • Sorry, I am using Maven as the build-tool. I am using IntelliJ version 13.1.4. – joey7492 Jan 16 '15 at 11:35
  • This still didn't work I am still getting the same error – joey7492 Jan 19 '15 at 15:42
  • Please edit your question and post a brief structure of your maven project structure. Additionally please post all parent maven projects' and the target maven project's pom.xml. I think it would also be helpful, if you show us the actual "java -jar /......" output/error message. – Ronald Duck Jan 20 '15 at 17:31
  • Thanks for your help, after going through the POM with a fine tooth comb I tweaked some paths and it works. – joey7492 Jan 23 '15 at 10:55
  • It seems someone has really worked very hard to not make it work. It is such a shame it never works. I have tried at least 50 different answers and none of it worked. And its the same story every single time. Now I reserve a week to just output it as a jar as everyone in our company thinks its a genuine effort that needs to be go in producing an output jar. – Awesome Jan 15 '18 at 09:01