Reputation: 2241
I made a small game in Java. It had about 5 different classes and the main class being in Game.java I compiled it into a jar file and I did everything correctly with my manifest.txt which gives the name of the file where the main class is in. The jar file worked on my computer so I then converted it into an exe file and sent it to someone else. When My friend tries to run the exe file, it gives him an error saying:
Could not find main class game. Now exiting.
The exe and jar file work fine on my computer but not on a different computer. We both also run Windows 7. What went wrong?
Upvotes: 1
Views: 1805
Reputation: 1584
I think you need to have every library used in your application beside your EXE file in lib folder. interestingly enough, when lib files are missing, the error shown is about main class, which is so not the case ;) anyway, I had the same problem and got it resolved by including lib folder beside my exe file. this is part of readme.txt generated by net-beans in dist folder, that might be helpful to you:
======================== BUILD OUTPUT DESCRIPTION
when you build an Java application project that has a main class, the IDE automatically copies all of the JAR files on the projects classpath to your projects dist/lib folder. The IDE also adds each of the JAR files to the Class-Path element in the application JAR files manifest file (MANIFEST.MF).
Upvotes: 2