Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2007, 09:53 PM   PM User | #1
Synaphor00449
New to the CF scene

 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Synaphor00449 is an unknown quantity at this point
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.
Synaphor00449 is offline   Reply With Quote
Old 06-01-2007, 11:27 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
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.
Step 1
Compile by executing javac *.java

Step 2
execute the following command

jar cvf MyApp.jar *.class

Step 3
Create a text file and call it Main.txt...then write the following inside it
Main-Class: MyApp

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.

Cheers,
Ess
ess is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:14 PM.


Advertisement
Log in to turn off these ads.