There is a maven project, created its jar file, when I run through the console, I get the error no mainfest attribute in Greeting.jar. In the console, I write java -jar Greeting.jar.

Manifest-Version: 1.0 Class-Path: D: \ Programming \ Projects \ Java \ Greeting \ src \ main \ java Main-Class: Main

in the environment settings, the PATH pointed out.

The file maven is written

http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0

<groupId>com.time</groupId> <artifactId>mainTime</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>com.time</groupId> <artifactId>mainTime</artifactId> <version>1.0-SNAPSHOT</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>Main</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> 

  • What are the plugins for building the project? Show from pom.xml part <build>....</build> - Chubatiy
  • <manifest> <addClasspath> true </ addClasspath> <mainClass> Main </ mainClass> </ manifest> I just found it on the Internet, but this option did not help ( - AlexanderBogomaz
  • Is it added to the build ? Bring pozh. for example the whole build section - Chubatiy
  • Here is the entire code from the maven file. - AlexanderBogomaz
  • Added answer, try - Chubatiy

1 answer 1

Try it like this. POM.xml should look something like this

  <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>com.time</groupId> <artifactId>mainTime</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.5</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>Main</mainClass> </manifest> </archive> <finalName>mainTime</finalName> </configuration> </plugin> </plugins> </build> </project>