Dist jar and exe not working - Cannot find Main

My project builds successfully, and runs via the sdk perfectly. Once I try to run it via the exe or the .jar in Dist/ it fails. The exe says nothing at all, but the .jar file says:


"cannot find x.y.z.Main. Program will exit"


I've verified that x.y.z is the correct path, and I've rebound the Main class in the project properties with no different results. Any suggestions?

To me, it would seem that your JRE (Java Runtime Engine) is not executing correctly. A simple solution may be to reinstall the JRE or your JDK. A JDK reinstall may give you configuration issues with any Java IDE you have installed, including JME3 SDK, especially if you upgrade the version.



However, before rushing ahead and reinstalling a whole lot of stuff, how about checking your .JAR file association. I use Windows 7, so I’ll put instructions on how to do that here. For this, we want to make sure that the .JAR file is associated with the JAVAW.EXE so that it will run with a double click. Do the following:


  1. Click on the Blue Ball with the Windows symbol in the lower left corner of the screen.
  2. Select Default Programs. It is the one above Help and Support.
  3. Select the second option “Associate a file type or protocol with a program”
  4. Wait for the screen to load … it can take a while.
  5. Find .JAR in the list of program extensions. Select it.
  6. Click on CHANGE PROGRAM.
  7. In the window that opens, click on BROWSE.
  8. Find the JAVAW.EXE program on your computer. It must have the W after Java.
  9. On my computer, the file is located in the folder “C:Program Files (x86)Javajre6bin”. It may well be a similar folder on yours.
  10. Click on OPEN.
  11. Click on OK.
  12. Click on CLOSE.



    Done. Now you should be able to run your .JAR file with a double click.





    I also put the above info into a read-me file that I distribute with my programs. And I also include a batch file to run the .JAR with contents like so:



    path = C:Program Files (x86)Javajdk1.6.0_26bin

    rem THE ABOVE PATH MAY NEED TO BE EDITED TO POINT TO THE FOLDER WHERE JAVAW.EXE IS LOCATED.

    java -jar myGame.jar myGame.Main

    pause





    I hope this helps. Cheers.