It depends. By default, the answer is yes, it does not contain this information.
But Maven can be configured to contain these things. To also include the dependencies, one could use the Maven Assembly plugin and bind it to the package phase with a jar-with-dependencies
setting, or use the Maven Shade plugin (also bound to the package phase). They are similar, although I prefer the Shade plugin as it supports so-called transformers that can work around some issues one gets when combining multiple jar files into one.
To have a main-class defined as entry point, you can configure the Maven compile plugin:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<mainClass>my.main.Class</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
If configured like that, you don't have to call java -cp my.jar my.main.Class arguments
, but can just call it as java -jar my.jar arguments
. If you still have additional dependencies, you would call it with java -jar my.jar -cp dependencies/*.jar arguments
.