Run java jar - no main manifest attribute error

Ive created a simple java program (maven with pom), which, when I run some command with CMD, should create a file at the given path ... I do mvn clean install that end successfully, now I want to use this created jar from the command line, as shown below:

java -jar   "/Users/i012/IdeaProjects/myproj/target/test.rts-1.0-SNAPSHOT.jar" path2genfile2create 

Why should my program run (this is the first time I try something like this ...)

But the error I get is:

no main manifest attribute, in /Users/i012/IdeaProjects/myproj/target/test.rts-1.0-SNAPSHOT.jar

What could be missing here? which exhibits the attribute ?

The error does not arise from the created class. ...

I created some META-INF / MANIFEST.MF without helping, but maybe wrong

+6
3

Maven IDE, mainClass. , :

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <mainClass>com.foo.MyMainClass</mainClass>
        </manifest>
      </archive>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
      <id>make-assembly</id>
      <phase>package</phase>
      <goals>
        <goal>single</goal>
      </goals>
      </execution>
    </executions>
  </plugin>
+6

- META-INF/MANIFEST.MF , , jar.

:

Manifest-Version: 1.0
Created-By: 1.7.0_06 (Oracle Corporation)

, Main-Class: classname.

jar , :

  • IDE, .
  • jar cfm MyJar.jar Manifest.txt MyPackage/*.class, .
  • , . .

jar .

+3

in my case, I used spring-boot, but I did not mention my creator in my pom, so I fixed it:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
0
source

All Articles