Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Running simple java apps/tools in CLI

Running simple java apps/tools in CLI
Thread Tools
Forum Regular
Join Date: Sep 1999
Location: Fort Wayne, IN USA
Status: Offline
Reply With Quote
Aug 25, 2001, 08:28 PM
 
I am taking an introductory course in programming that is based on Java. Since the first few programs are small and are CLI only. The programs complie and run in Project Builder with no problem but when I try to launch them from the terminal with the command:
java -jar RainFall.jar

I get the following error:
Failed to load Main-Class manifest attribute from RainFall.jar

I am doing wrong? The project type I chose in Project Builder was Java Tool. The source code is here. Thanks.

Dr Evil
Quicksilver G4 867mhz 384mb/60gig
iBook 300 320mb/20gig
Athlon Xp 1700+(1.47GHz) 512mb ddr/26gig, GeForce 4 TI 4200/128mb
http://mayodreams.dyndns.org
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Aug 25, 2001, 11:58 PM
 
Ahh, the "Black Art" of the executable .jar. The .jar needs to be told which class holds the main() method. The Manifest holds this little bit of information and you can create it in TextEdit then graft it into the .jar afterwards.

1) You need an empty text file usually named manifest.tmp
2) the first lines of text should be:

"Main-Class: MyClassName.class <cr>
<cr>"

where you MUST have 2 carriage returns or it will not work.

3) Now graft the manifest in with a:

"jar cfm myJar.jar manifest.tmp"

4) you could then try to execute --or-- verify the manifest made it in with a
"jar tvf myJar.jar"
to list the .jar's contents

This whole process is a royal pain in the butt and rarely works the first time for me. I usually re-consult my notes, book and buddy in that order. Then swear profusely at the machine before realizing it has finally taken. The process is easier but flakier when you use an IDE to help with the .jar-ing process.

Good Luck!

[ 08-26-2001: Message edited by: AirSluf ]
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2