[英]Jar in a jar build with maven
I am trying to create a .jar for my app. 我正在尝试为我的应用创建一个.jar。 This app contains many things such as another .jar.
这个程序包含许多东西,例如另一个.jar。
Using this plugin in my pom configuration : 在我的pom配置中使用此插件:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.rilent.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
And I have this link to a local jar 我有这个链接到本地罐子
...
<dependency>
<groupId>it.sauronsoftware.jave</groupId>
<artifactId>jave</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jave-1.0.2.jar</systemPath>
</dependency>
I am using this command to build my app which returns BUILD SUCCESS : 我正在使用此命令来构建返回BUILD SUCCESS的应用程序:
mvn clean compile assembly:single
but when I try to execute my program, It crashes at some point returning this error : 但是,当我尝试执行程序时,它在崩溃时返回此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: it/sauronsoftware/jave/InputFormatException
( a class from the .jar)
I tried decompressing my main jar to see its content : 我尝试解压缩主jar以查看其内容:
what is wrong with the way I am creating my jar? 我创建罐子的方式有什么问题?
edit @Thorbjørn Ravn Andersen 编辑@ThorbjørnRavn Andersen
I tried this way too, I added this to my pom : 我也尝试过这种方式,将其添加到pom中:
<!-- https://mvnrepository.com/artifact/com.jolira/onejar-maven-plugin -->
<dependency>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
</dependency>
then I m compiling with mvn compile
and when I try to run the .jar I get this error 然后我用
mvn compile
,当我尝试运行.jar时,出现此错误
no main manifest attribute, in .\\myapp-0.0.1-SNAPSHOT.jar
what am I doing wrong again ...? no main manifest attribute, in .\\myapp-0.0.1-SNAPSHOT.jar
,我又在做什么错...?
Note : My jar also contains a .exe 注意:我的jar也包含一个.exe
The standard classloaders cannot load classes from jars inside jars. 标准类加载器无法从jar内的jar加载类。 EXE files cannot be run from inside jars.
EXE文件无法从jar内运行。
This does not mean that it is impossible, but a bit cumbersome and perhaps above your current skill level. 这并不意味着这是不可能的,而是有点麻烦,也许超出了您当前的技能水平。 You might find One Jar ( http://one-jar.sourceforge.net/ ) interesting as it automates exactly this.
您可能会发现One Jar( http://one-jar.sourceforge.net/ )很有趣,因为它可以自动执行此操作。
For a Maven project I have had good experience with creating a deployment structure and scripts with appassembler. 对于Maven项目,我在使用appassembler创建部署结构和脚本方面拥有丰富的经验。 http://www.mojohaus.org/appassembler/appassembler-maven-plugin/
http://www.mojohaus.org/appassembler/appassembler-maven-plugin/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.