1
votes

I using Swing GUI Form in my program. In IntelliJ IDEA all work fine, but after packaging via Maven I get the error:

C:\Work\Idea\XLSConfigurdator\target>java -jar xlsconfigurdator-parent-1.0.jar. Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesign er/core/GridLayoutManager at XLSCreator.$$$setupUI$$$(XLSCreator.java) at XLSCreator.(XLSCreator.java:24) at XLSCreator.main(XLSCreator.java:73) Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLa youtManager at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more

C:\Work\Idea\XLSConfigurdator\target>java -jar xlsconfigurdator-parent-1.0.jar Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesign er/core/GridLayoutManager at XLSCreator.$$$setupUI$$$(XLSCreator.java) at XLSCreator.(XLSCreator.java:24) at XLSCreator.main(XLSCreator.java:73) Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLa youtManager at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more

"main" method only run constructor of class, constructor configured GUI Form via $$$setupUI$$$() method (File - Settings - Generate GUI into: Java source code).

public static void main(String[] args) {
    new XLSCreator();

    sourceClass sc = new sourceClass();
    array = sc.readFromExcel(fileName);
}

public XLSCreator() {
    $$$setupUI$$$();
    setContentPane(rootPanel);
    setVisible(true);
    setSize(500, 200);
    setTitle("I'll save your mistakes");

    aceptButton.addActionListener(this);
**etc**
...
}

I read all topics about this error, I added all dependencies into pom.xml (poi, poi-ooxml, swingx, forms_rt, ideauidesigner-maven-plugin, junit, forms, javac2), all needed plugins (maven-jar-plugin, ideauidesigner-maven-plugin) but still have problem with GridLayoutManager after packagin.

1
Is the space at uiDesign ercorrect and have you tried after you removed it? - Reporter
That you define the dependencies in you pom, doesnt mean that they are on classpath when you run the delivered release. In the IDE's the workspace is in classpath and with maven, the maven repo is in classpath. You need configure your classpath. - Henning Luther
You may have an older version of forms_rt.jar in the classpath. Try the one from IDEA_HOME/redist. - CrazyCoder
Open the generated fat JAR and see if you can find the JAR that contains that class. If you can't see it the JVM won't be able to, either. You have a packaging issue. - duffymo
How i need configure my classpath? I use latest version of forms_rt.jar and into my .jar file i see only my classes - Alexey Vysotsky

1 Answers

0
votes

Thanks for all, you are best.

But I forgot paste into pom.xml maven-compiler-plugin and configure it

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <archive>      
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>XLSCreator</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>