无法找到或加载主类 Swing Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9699437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not find or load main class Swing Java
提问by Syed Muhammad Mubashir
Error: Could not find or load main class jewelleryerpapplication.GUI.ERPMainMenu Java Result: 1
错误:无法找到或加载主类 Jewelleryrpapplication.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. 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.
实际上,我使用的是 Net Beans 7.1,因此我不断收到相同的错误,但即使在为此安装了最新更新后也无法获得解决方案。我从创建新项目并复制该项目中的源和库折叠的某个机构获得的解决方案从前一个项目中得到了上述错误。这个解决方案对我有用,但我需要一些更简单的解决方案来解决这个问题。非常感谢。如果有帮助,请不要忘记放弃投票。
采纳答案by npinti
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;
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)
. 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. 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. You can start by either checkin gout thisprevious 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. You can also try and see if you get the same issue if you use a different IDE such as Eclipse.
如果这是第三方应用程序,则您的类路径中没有包含一些 jar 文件;
或者,(在我看来这是最有可能的)您没有具有以下签名的方法:
public static void main(String[] args)
. 此方法定义了应用程序的主要入口点,当您尝试运行项目时,没有它可能会导致该错误。据我所知,每当您创建新项目时,Netbeans 都会自动创建一个具有此类方法的主类。这可能是您在创建新项目并将所有内容放入其中时没有出现此异常的原因。您可能遇到了 Netbeans 本身的问题。您可以通过签入痛风启动此之前的SO线程在一个类似的(我认为)正在讨论的问题,否则,作为最后的手段,你可能想要删除Netbeans和它的所有文件,并安装一个早期版本。如果您使用不同的 IDE(例如 Eclipse),您也可以尝试查看是否会遇到相同的问题。
回答by Rakesh
Right click on project node, go to Set configuration, select the main class for your application. Then clean and build.
右键单击项目节点,转到Set configuration,选择应用程序的主类。然后清理并构建。
Even if this doesn't solve your problem, then delete the Netbeans cache by deleting the (index) folder
即使这不能解决您的问题,也请通过删除 (index) 文件夹来删除 Netbeans 缓存
User\.netbeans.9\var\cache\index\
回答by attah
the solution is,right click your package in netbeans,go to properties,source now go to the jre option and choose your version,the programme will now run.
解决方案是,在netbeans 中右键单击您的包,转到属性,源现在转到jre 选项并选择您的版本,程序现在将运行。