Could not find main class?

I have a hard time with a Java error. I get this by double-clicking on my compiled project Jar file to run it:

Could not find the main class: testPackage.testFrame. Program will exit. 

However, my main class is clear, defined in the project properties. In addition, everything works fine when I run the project directly from NetBeans.

I use the third-party ip2c.jar library to identify countries by IP address. If I comment on a class that uses the ip2c.jar file, I do not get an error.

How can a third-party library prevent the JVM from finding my main class?

+1
source share
4 answers

If I comment on a class that uses the ip2c.jar file, I do not get an error.

Is this when you comment on the above use, are some classes going right? and when you turn it on, do you have some error due to which the .class class is not generated for your main class? - just a hint as a third-party bank will not interfere with the work of META-INF / MANIFEST.MF in the main bank.

+3
source

If you want to launch the application by clicking on the bank, you need to specify the main class in the META-INF/MANIFEST.MF file in the bank, as described here . Make sure you identify it correctly.

You should be able to do this in Netbeans while creating your jar file.

You can also find this question in the "Useful" section.

+6
source

I also had this problem. It happens that Java does not tell you ERROR correctly. While my Main class was right, he told me that my Main class was not found. My mistake was that I did not copy the new library to the lib folder outside Netbeans. Hope you get it. I mean, I created a folder to run my JAR file, in this folder I have a lib folder that I copied from my project. This may not sound very clear, if anyone has this error, I can help you. Thanks.

+2
source

You need to make sure that your manifest is correct in the correct directory (which seems to be accurate, then the error message contains the class name) and that the class is in the JAR and is packed with the correct directory structure that matches its packaging structure.

+1
source

All Articles