JAR doesn't work with Absolute Layout

不打扰是莪最后的温柔 提交于 2019-12-02 07:18:35

问题


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.

I would appreciate very much any help/tips/info from anyone on this subject.

Thank you very much for your time.


回答1:


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




回答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.




回答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!



来源:https://stackoverflow.com/questions/25586038/jar-doesnt-work-with-absolute-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!