JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.39k stars 269 forks source link

Running built jar throwing error, running it from the IDE does not. #585

Closed rosariop closed 2 years ago

rosariop commented 2 years ago

Building the project via maven 3.8.6. Running the Project via IntelliJ "Playbutton" it works like a charm but running the built jar does not.

PS C:\Users\Polito\Documents\IdeaProjects\podcastr-java\target> java -jar .\podcastr.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/formdev/flatlaf/FlatDarculaLaf
        at de.podcastr.desktop.view.MainWindow.start(MainWindow.java:14)
        at de.podcastr.desktop.Podcastr.main(Podcastr.java:7)
Caused by: java.lang.ClassNotFoundException: com.formdev.flatlaf.FlatDarculaLaf
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 2 more

build part of the pom.xml

<build>
        <finalName>podcastr</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>de.podcastr.desktop.Podcastr</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
DevCharly commented 2 years ago

ClassNotFoundException means that Java can not find the class 😉

Please check the classpath in the META-INF/MANIFEST.MF file in podcastr.jar.

DevCharly commented 2 years ago

Does it work now? If yes, please close the issue.