0

We have this small program we made and we wanna create an executable 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:

<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:

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
LeonSteinn
  • 19
  • 3
  • 1
    the problem is not the main class, but the dependencies, see https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Turo May 28 '20 at 09:15
  • OK, I changed it to maven-assembly-plugin but now I am having the error I get too many times, my plugins and dependencies are not being found - the artifactIds being red in the pom file. – LeonSteinn May 28 '20 at 09:24
  • You need to learn how to properly package a Java program. Unfortunatly this is one of the things that typically are hard as Java until recently has not had a standard functionaltiy for this – Thorbjørn Ravn Andersen May 28 '20 at 10:48

1 Answers1

0

try dependency !?

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
</dependency>
Ray Lee
  • 34
  • 4