When I create a jar with SVcode and try to open it at the command prompt

Error: Unable to initialize main class henkan.App
Cause: java.lang.NoClassDefFoundError: org/apache/poi/EncryptedDocumentException

When I investigated it in detail, it seems that it is stuck in the XSSF Workbook, I think that the setting in pom.xml is probably the problem, but I can not find a solution

<? xml version = "1.0" encoding = "UTF-8"?><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>henkan</groupId> te</artifactId><version>1.0-SNAPSHOT</version><name>te</name><!-FIXME change it to the project's website-><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>15</maven.compiler.source><maven.compiler.target>15</maven.compiler.target></properties><dependencies><dependency>  <groupId>junit</groupId>     junit</artifactId>  <version>4.11</version>  <scope>test</scope></dependency><dependency>  <groupId>org.apache.poi</groupId>     poi</artifactId>  <version>4.1.2</version></dependency><dependency>  <groupId>org.apache.poi</groupId>     poi-ooxml</artifactId><version>4.1.2</version></dependency></dependencies><build><pluginManagement><!-Lock down plugins versions to avoid using Maven defaults (may be moved to parent pom)->  <plugins>    <!-clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle->    <plugin>         maven-clean-plugin</artifactId>      <version>3.1.0</version>    </plugin>    <!-default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging->    <plugin>         maven-resources-plugin</artifactId>      <version>3.0.2</version>    </plugin>    <plugin>         maven-compiler-plugin</artifactId>      <version>3.8.0</version>    </plugin>    <plugin>         maven-surefire-plugin</artifactId>      <version>2.22.1</version>    </plugin>    <plugin>         maven-jar-plugin</artifactId>      <version>3.0.2</version>    </plugin>    <plugin>         maven-install-plugin</artifactId>      <version>2.5.2</version>    </plugin>    <plugin>         maven-deploy-plugin</artifactId><version>2.8.2</version>    </plugin>    <!-site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle->    <plugin>         maven-site-plugin</artifactId>      <version>3.7.1</version>    </plugin>    <plugin>         maven-project-info-reports-plugin</artifactId>      <version>3.0.0</version>    </plugin>    <plugin>      <groupId>org.apache.maven.plugins</groupId>         maven-jar-plugin</artifactId>      <configuration>                   <manifest>          <mainClass>henkan.App</mainClass>             true</addClasspath>             true</addExtensions>        </manifest>       </archive>      </configuration>    </plugin>  </plugins></pluginManagement></build></project>

I'd like to add a plugin, what should I do?

The procedure at the time of creation was created with mvn package (no warning such as error at this time)
The way to open it is as above when trying to open it with java -jar at the command prompt.

  • Answer # 1

    Create a jar with SVcode

    Please tell me the operation procedure when it was created.

    When I try to open it at the command prompt

    What command did you type at the command prompt?

    Do you know how to unzip the jar file?
    If you know, unzip it to a suitable folder and it will be included in itMANIFEST.MFPlease tell me the contents of the file.

    2020-11-24 postscript

    java -jar hoge.jarTo run onhoge.jarIn,henkan.AppNot only should it contain the class files for all dependent libraries (so-called executable jars).
    Probablymvn packageIn the jar file created inhenkan.AppIsn't it only the class file of?jar tvf hoge.jarYou can see it if you do). In that case, you need to specify the classpath to the dependent library at runtime.

    I think you can make an executable jar by the following method, so please try it (I don't know if this is an orthodox method).

    (1)pom.xmlAdd the following plugins to


    (2) Execute the following command in the terminal

    $mvn clean compile assembly: single

    with this,targetUnder the directoryxxxxx-with-dependencies.jarI think you can.

    (3) Execute

    $java -jar target/xxxxx-with-dependencies.jar