3

I've never built an executable .jar before, and I'm trying to do so with a Maven project with IntelliJ, and I can't seem to run the program. I've done it through the Project Structure -> artifacts route, and I've set the main class and locations properly or so I thought, in the configuration:

in my pom.xml

        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
                <configuration>
                    <classifier>spring-boot</classifier>
                    <mainClass>
                        app.ContactRunner
                    </mainClass>
                </configuration>
            </execution>
        </executions>
    </plugin>

And here's a screenshot of the project structure along with the MANIFEST.MF

Screenshot

What's missing that I need to add in order to execute this jar? Thanks for the help!

EDIT-=-=-=

I have removed the packaging structure, and it is now just app.ContactRunner with nothing extra in the MANIFEST file.

Community
  • 1
  • 1
NateH06
  • 3,154
  • 7
  • 32
  • 56
  • 2
    Try to remove src.main.java.app from the main class, this does not look like a valid classpath. – Patrick Oct 11 '17 at 19:05
  • It was originally `app.ContactRunner` but that didn't work. – NateH06 Oct 11 '17 at 19:06
  • Also, it won't allow me to fully remove it all, `app` still needs to be in there. – NateH06 Oct 11 '17 at 19:12
  • 1
    If you open the jar file (it's just a zip file with another extension) and look at the `META-INF/MANIFEST.MF` file, does *it* have the `Main-Class` attribute? – Andreas Oct 11 '17 at 19:36
  • It does not. This was automatically generated though. How do I re-zip it back into a .jar file? – NateH06 Oct 11 '17 at 19:42
  • `src.main.java` is not part of the package name and should **not** be included in the fully qualified classname. Check the `package ...` definition at the top of that source file. –  Oct 11 '17 at 19:43
  • @a_horse_with_no_name I took that out and changed it to just `app.ContactRunner`, still same issue – NateH06 Oct 11 '17 at 19:45
  • 2
    I don't use IntelliJ, but the hint "*You are editing a file which is ignored*" seems to indicate that IntelliJ (or your Maven build) generates the manifest in a different way. –  Oct 11 '17 at 19:46

1 Answers1

3

I had to move where the MANIFEST folder was. It was putting it under

/src/main/java/

and it needed to be under

/src/main/resources

As taken from this answer: https://stackoverflow.com/a/21074091/7082628

NateH06
  • 3,154
  • 7
  • 32
  • 56