Could not find or load main class Swing Java
Asked Answered
M

3

7

Error: Could not find or load main class jewelleryerpapplication.GUI.ERPMainMenu Java Result: 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.

Manlike answered 14/3, 2012 at 9:47 Comment(2)
did you try clean and build ?Hluchy
yes i tired cleen and build many times even i close net beans and open it again and clean and build it but that didn't helped me.Manlike
G
4

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 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. You can also try and see if you get the same issue if you use a different IDE such as Eclipse.

Gallium answered 14/3, 2012 at 9:59 Comment(2)
No this is not third party application and i am just creating a swing project using NetBeans and i create the application which has public static void main(String[] args) function , even with the presence of main function i get this exception some time and unable to execute and most of time my application works fine.Manlike
@Prog_Anila: I have modified my answer. Hopefully what I said will solve your issue.Gallium
H
6

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

User\.netbeans\6.9\var\cache\index\
Hluchy answered 14/3, 2012 at 10:30 Comment(4)
Dear Rakesh i applied your solution for the setting configuration and now it works for me . I am Really thankful to you for this favour.Manlike
Well, that is why I am here on SO ! :-)Hluchy
Your solution is working for some exception but now i am getting another exception as below and i am applying both of the solution but now both of the solution is not working for meManlike
i found that by running javac -version i found that javac 1.7.0_02 was installed in my system now please tell which of the 3 i may install 1)Java EE 6 SDK with JDK 7 U3 2)Java EE 6 SDK 3)Java EE 6 SDK Web Profile ots of thanks in advanceManlike
G
4

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 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. You can also try and see if you get the same issue if you use a different IDE such as Eclipse.

Gallium answered 14/3, 2012 at 9:59 Comment(2)
No this is not third party application and i am just creating a swing project using NetBeans and i create the application which has public static void main(String[] args) function , even with the presence of main function i get this exception some time and unable to execute and most of time my application works fine.Manlike
@Prog_Anila: I have modified my answer. Hopefully what I said will solve your issue.Gallium
W
0

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.

Warder answered 18/4, 2012 at 3:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.