如何使用命令行运行maven创建的jar文件 [英] How to run a maven created jar file using just the command line
本文介绍了如何使用命令行运行maven创建的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一些帮助,尝试使用命令行运行以下maven项目:
https://github.com / sarxos / webcam-capture ,webcam-capture-qrcode示例是我正在尝试运行的示例。我使用Eciplse IDE运行它,但需要将其移动到仅使用命令行。我有由maven创建的jar。
I need some help trying to run the following maven project using the command line: https://github.com/sarxos/webcam-capture, the webcam-capture-qrcode example is the one I'm trying to run. I have it running using an the Eciplse IDE but need to move it over to just using the command line. I have the jar's created by maven.
我正在尝试
java -classpath ./webcam-capture/target/webcam-capture-0.3.10-SNAPSHOT.jar com.github.sarxos.webcam.WebcamQRCodeExample
但我一直得到
Exception in thread "main" java.lang.NoClassDefFoundError: com/github/sarxos/webcam/WebcamQRCodeExample
Caused by: java.lang.ClassNotFoundException: com.github.sarxos.webcam.WebcamQRCodeExample
推荐答案
只需使用 exec-maven-plugin
。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.example.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
然后你运行程序:
mvn exec:java
这篇关于如何使用命令行运行maven创建的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文