4

I have written some GUI program in netbeans which makes use of swing and it's working fine.I created jar file by right-clicking on project>clean and build and all the resources are included in it from project properties.The jar file in dist folder is executing through commandline using

java -jar mig_log.jar

but whenever I double click the jar file it says "Could not find the main class.Program will exit". I referred these links but nothing worked out : producing executable jar in netbeans

Could not find the main class

Community
  • 1
  • 1
crazy4
  • 135
  • 1
  • 2
  • 10

1 Answers1

2

In Netbeans, go to Properties of project, then in Run tab browse and select Main Class that has main() method which starts your GUI, and then clean and build to create jar file. Now double clik JAR file, and let me know result.

nullptr
  • 3,320
  • 7
  • 35
  • 68
  • the Main Class has already set to mig_log.Mig_log so the result is same. – crazy4 Jan 03 '13 at 16:58
  • do u mean u get Error Dialog on double click? – nullptr Jan 03 '13 at 17:01
  • yes,exactly. When I run through commandline everthings works fine but on double-click it shows error. – crazy4 Jan 03 '13 at 17:03
  • http://stackoverflow.com/questions/9612918/could-not-find-the-main-class-error-when-running-jar-exported-by-eclipse this may help.. see answer.. – nullptr Jan 03 '13 at 17:15
  • that's not perfect way, have you gone through question as I pointed link? You might have some Java versions clash. Your netbeans may be running on different Java version than you have provided as Path in System. Check which Java installation is being used by Netbeans and to which version you have set path. – nullptr Jan 03 '13 at 18:03
  • I have re-installed java on my machine and now it's working fine.The file is executing.Actually the ftype issue was there.Thanks a lot. – crazy4 Jan 04 '13 at 13:40