Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
06-01-2007, 09:53 PM #1
- Join Date
- Jun 2007
- Thanked 0 Times in 0 Posts
Executable jar file,Main-class manifest,Error: Can't Find Main class
I have a file called piggybankrun. It contains five(5) source files(including one called PiggyBankMain.class, which has only the class title and public static void main(String)), and a manifest file. The manifest file has a single line of code: "Main-Class: PiggyBankMain" I typed a carriage return after. I am using the cmd.exe to put the jar file together. After getting to the 'bin' folder I type:
...>jar cfm f:\piggybank.jar f:\piggybankrun\manifest.mft f:\piggybankrun\*
It creates a .jar file successfully. I double click on the .jar file and it says: "Could not find the main class. Program will exit."
If you could, please explain where I may have screwd up. If I left out some information you need please ask. Thanks.
PS: If it matters I'm using a JFrame that pops up. Thanks again.
06-01-2007, 11:27 PM #2
- Join Date
- Oct 2006
- United Kingdom
- Thanked 29 Times in 28 Posts
Have you tried to view the contents of the Jar File? Usually, I inspect the contents using WinRar...by just opening the contents of the jar file.
Try doing it the following way.
Compile by executing javac *.java
execute the following command
jar cvf MyApp.jar *.class
Create a text file and call it Main.txt...then write the following inside it
Don't forget to add an empty line after the "Main-Class: MyApp"
Once you have done that, execute the following command to update the JAR file with the mainifest
jar umf Main.txt MyApp.jar
That should do the trick
If that doesn't work...try the following command
java -jar MyApp.jar
in case your path is not configured correctly.