NoClassDefFoundError when trying to run JAR which uses Absolute Layout

10,725

Solution 1

Try add the AbsoluteLayout jar file as a library and import the AbsoluteLayout from that library. You can get the jar from here.

Solution 2

I already fix the problem.

I didn't realize that the AbsoluteLayout class was something exclusive to NetBeans - I guess I thought it was a built-in swing layout manager. I added the AbsolutLayout class to my JAR and everything works great.

Solution 3

Its a problem with the classpath, i assume.

Your executable JAR File should contain a manifest file (see META-INF folder).
In this manifest-file, all needed libraries are listed (including path to this libs!)

Check your JARs manifest file and check if the libs (in your case AbsoluteLayout.jar) are really
in the place specified.

Example:
When your JAR is in Folder: C:/Test/App.jar and your Manifest looks like
...
Class-Path: libs/AbsoluteLayout.jar
...

then this file must exist here: C:/Test/libs/AbsoluteLayout.jar !

PS: Using multiple Jars is "not" a problem for a WebStart-Applications! In JNLP file, the AbsoluteLayout.JAR also must be specified!

Share:
10,725
Yulz
Author by

Yulz

Updated on June 05, 2022

Comments

  • Yulz
    Yulz almost 2 years

    I have developed a swing GUI for my program using the NetBeans form editor. I used the AbsoluteLayout so that I could click and drag components to wherever I needed them to go on the frame. The problem is that when I try to run the executable JAR file that I made for the program, I get the following error:

    java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout ...Exception in thread "main"

    All of the GUI code was written for me by NetBeans so I'm not sure what the problem is here.

    I really like using the form editor because getting GUI's to look like I want them to is extremely tedious when I try to hard-code it myself. The program needs to be used for JavaWebStart and so it has to be in a working executable JAR file.