0

I'm working on a project using Flatlaf look and feel. I'm using NetBeans. It runs ok in NetBeans. I want to build a standalone application for Windows.

I used WiX to build a standalone application for Windows. WiX builds the msi installer using the command:

jpackage --input . --win-console --name MyProj --main-jar myProj-1.0.jar --main-class myname.myproj.MyProj --type msi

After installed, running the application I read the error:

Error: Unable to initialize main class myname.myproj.MyProj Caused by: java.lang.NoClassDefFoundError: com/formdev/flatlaf/FlatDarkLaf Child process exited with code 1 Here is the simplified code MyProj.java:

package myname.myproj;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class MyProj {

    public static void main(String[] args) throws UnsupportedLookAndFeelException {
        UIManager.setLookAndFeel(new com.formdev.flatlaf.FlatDarkLaf());
        JFrame myFrame = new JFrame("Frame");
        myFrame.setSize(333, 333);
        myFrame.setVisible(true);
    }
}

And here is the pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>MyName</groupId>
    <artifactId>myProj</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>com.formdev</groupId>
            <artifactId>flatlaf</artifactId>
            <version>2.0.2</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>18</maven.compiler.source>
        <maven.compiler.target>18</maven.compiler.target>
        <exec.mainClass>myname.myproj.MyProj</exec.mainClass>
    </properties>
</project>

EDIT: It doesn't need to be standalone, but I can't make it work compiling to jar. If someone has a solution about compiling to jar, it will be helpful.

0 Answers0