简体   繁体   English

Netbeans dist jar文件给出NoClassDefFoundError

[英]Netbeans dist jar file giving NoClassDefFoundError

Yes I have a project that I'm working on in NetBeans 7.1 and I come to the point where I want to use the jar file on a different computer but when I try to run it it gives a NoClassDefFoundError. 是的,我有一个正在NetBeans 7.1中进行处理的项目,现在我想在另一台计算机上使用jar文件,但是当我尝试运行该项目时,它给出了NoClassDefFoundError。 But when I run it on my computer it works fine. 但是,当我在计算机上运行它时,它可以正常工作。 I've extracted the .jar file all the classes seem to be there. 我已经提取了所有类似乎都存在的.jar文件。 I've checked to see if netbeans thinks my project is the main project and that it has a main class which I also confirmed in the MANIFEST.MF file. 我检查过netbeans是否认为我的项目是主项目,并且它具有主类,我也在MANIFEST.MF文件中确认了该类。 My program does have swing components if that affects anything. 我的程序确实有摆动组件,如果它影响任何因素。

Edit Also there are no other folders in my dist folder like any lib or picture folders I have also clean and rebuilt about a hundred times /Edit 编辑我的dist文件夹中也没有其他文件夹,就像我也清理过并重建过约一百次的任何lib或图片文件夹一样/ Edit

Here is the error 这是错误

Caused by: java.lang.ClassNotFoundException: ClubControl.jar
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

I have searched through countless articles on this subject and still I don't think I have found the problem. 我搜索了无数有关此主题的文章,但我仍然认为没有发现问题。 Hopefully I didn't miss it and someone responds with a link to another question. 希望我不会错过它,有人会回答另一个问题。

If any other info is needed just ask. 如果需要任何其他信息,请询问。

Edit 编辑

here is the MF file 这是MF文件

    Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_01-b08 (Oracle Corporation)
Class-Path: 
X-COMMENT: Main-Class will be added automatically by build
Main-Class: GUI.MainWindow

From the exception stacktrace it would seem that a class is misnamed somewhere in your code: 从异常stacktrace看来,类在您的代码中某处被错误命名:

Caused by: java.lang.ClassNotFoundException: ClubControl.jar
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

It appears to be trying to load up a class named ClubControl.jar - there should be no extension on the name, and definitely not a .jar one. 它似乎正在尝试加载名为ClubControl.jar的类-名称上应该没有扩展名,而且绝对不是.jar

You have to include other dependencies of the .jar. 您必须包括.jar的其他依赖项。 Like /lib folder or sometimes if you have images on the project you have to include those as well and make sure that the .jar can locate those dependencies. 像/ lib文件夹一样,有时,如果项目上有图像,则还必须包括这些图像,并确保.jar可以找到那些依赖项。 And try to Clean and Build the Netbeans project. 并尝试清理并构建Netbeans项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM