简体   繁体   English

无法找到或加载主类Swing Java

[英]Could not find or load main class Swing Java

Error: Could not find or load main class jewelleryerpapplication.GUI.ERPMainMenu Java Result: 1 错误:无法找到或加载主类jewelleryerpapplication.GUI.ERPMainMenu Java结果:1

Actually i am using Net Beans 7.1 and in that i am continuosly getting the same error but un able to get the solution for that even after installing the latest update for that. 实际上我正在使用Net Beans 7.1,因为我不断获得相同的错误,但即使在安装了最新的更新之后也无法获得解决方案。 The solution which i got from some body that create new project and copy the source and library foldes in that Project from the previous which generate the above error. 我从一些创建新项目的主体获得的解决方案,并从之前的项目中复制源项目和库文件,产生上述错误。 this solution works for me but i need some simpler solution for this problem.Lot of thanks in advance. 这个解决方案适合我,但我需要一些更简单的解决方案来解决这个问题。提前谢谢。 Don't Forget To Give UpVote It If It Helps. 如果它有帮助,不要忘记放弃投票。

Right click on project node, go to Set configuration , select the main class for your application. 右键单击项目节点,转到设置配置 ,选择应用程序的主类。 Then clean and build. 然后清洁和建立。

Even if this doesn't solve your problem, then delete the Netbeans cache by deleting the (index) folder 即使这不能解决您的问题,也可以通过删除(索引)文件夹来删除Netbeans缓存

User\.netbeans\6.9\var\cache\index\

I think that the following is happening: 我认为发生了以下情况:

  • If this is a third party application, you have not included some jar files on your class path; 如果这是第三方应用程序,则您没有在类路径中包含一些jar文件;

  • Or, (which in my opinion is the most likely) you do not have a method which has this signature: public static void main(String[] args) . 或者,(在我看来最有可能)你没有一个具有这个签名的方法: public static void main(String[] args) This method defines the main entry point for your application, not having it might cause that error when you try and run the project. 此方法定义应用程序的主入口点,而不是在尝试运行项目时可能导致该错误。 To my knowledge, Netbeans creates a main class with such a method automatically whenever you create a new project. 据我所知,Netbeans会在您创建新项目时自动创建一个具有此类方法的主类。 This might be the reason why you are not having this exception when you create a new Project and throw everything in it. 这可能是您在创建新项目并将其中的所有内容都抛出时没有此异常的原因。

  • You might be having an issue with Netbeans itself. 您可能遇到Netbeans本身的问题。 You can start by either checkin gout this previous SO thread in which a similar (I think) issue is being discussed, or else, as a final resort, you might want to remove Netbeans and all its files, and install an earlier version. 你可以先检查一下之前正在讨论类似(我认为)问题的SO线程,或者作为最后的手段,你可能想要删除Netbeans及其所有文件,并安装早期版本。 You can also try and see if you get the same issue if you use a different IDE such as Eclipse. 如果使用其他IDE(如Eclipse),也可以尝试查看是否遇到同样的问题。

解决方案是,右键单击netbeans中的包,转到属性,源现在转到jre选项并选择您的版本,程序现在将运行。

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

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