简体   繁体   English

Jar 可执行文件,但找不到主 class 的类路径

[英]Jar executable but can not find the classpath for main class

We have this small program we made and we wanna create an executable jar.我们制作了这个小程序,我们想创建一个可执行的 jar。 Screenshot of my maven dependency and the project structure The problem is that I use Maven install and create a jar and in my pom, I have this plugin:我的 maven 依赖项和项目结构的屏幕截图问题是我使用 Maven 安装并创建 jar 并在我的 pom 中,我有这个插件:

<plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

I have been trying Project.Main and as in the code just Main ( Main) but I do always get this error in the terminal:我一直在尝试 Project.Main 并且在代码中只是 Main ( Main ),但我总是在终端中收到此错误:

java -jar /home/haraldur/Desktop/Skolinn/508/Project/target/Project-1.0.jar
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

try dependency??试试依赖??

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM