Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJD- problem making jar - project from Andrew Monkhouse and Terry Camerlengo book

 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to build and run the project from Andrew Monkhouse and Terry Camerlengo book

I am having trouble with Manifest.mf and the jar file.

I am working on Windows vista system.

my manifest.mf file is as follows ( described in the book)



and when I run the project with the following command

C:\SUNcertification\SCJD\dennysDVDs>java -jar sampleproject.jar alone

I get

Failed to load Main-Class manifest attribute from
sampleproject.jar

I looked at my sampleproject.jar file and it has META_INF/MANIFEST.MF which obviously does not have



It looks like it is ignoring my manifest.mf file and creating default one. default MANIFEST.MF file does not know anything about
sampleproject.gui.ApplicationRunner

I am not getting it....how to solve this problem so the jar is built correctly to have the correct manifest.mf.

Please heeeeeeeeelp. I am stuck.

Thanks in advance.

Anu

 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, champ!

Instead of META_INF, try META-INF and let's see if this is the problem.
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roberto,

Thanks for the quick response.

it is actually META-INF/MANIFEST.MF

and the file I created is Manifest.mf

so why my Manifest.mf is ignored?


 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anu

Can you please show us the commands you used to create the Jar file?
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Andrew,

Thank you very much for the response.

This is what I did.

I created a manifest file Manifest.mf in my DVDproject directory (This is the project root)
Content of manifest.mf are as below. (Page 303 in the book)

Manifest-Version: 1.0
Main-Class: sampleproject.gui.ApplicationRunner

next I created the sampleproject in the root directory using the command

jar -cfm sampleproject.jar Manifest.mf -C classes . (P 306 in the book)

at this time I get sampleproject.jar in the root dorectory.

now i used the command

java -jar sampleproject.jar alone ( also tried java -jar sampleproject.jar alone) (P307 in the book)

and I get the error

Failed to load Main-Class manifest attribute from
sampleproject.jar

I looked at my sampleproject.jar file and it has META_INF/MANIFEST.MF which gets created by Sun (default). so it has ignored my Manifest.mf don't know why. Please help me get unstuck ....

Regards,

Anu


 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow - this is a bit of a stumper. The commands all look correct, and since you have not mentioned getting any errors or warnings, it appears that the commands are correct.

The only thing I can think of is that there used to be a bug in versions of the Jar tool up until at least version 1.4, although I have not heard of it happening since that time. The bug was that the jar tool refused to read a manifest file that did not contain one blank line following the stanzas. The way around it was to force blank lines into the desired manifest file (some editors in Microsoft Windows tried to remove them, making it difficult). So the manifest file would become:


Note that I have included 2 blank lines in that example, and had to put spaces in it to get around JForum trying to helpfully remove unneeded lines. Normally you would not have the spaces. Having 2 blank lines used to get around the Microsoft feature of removing the last blank line from a file - there would still be one blank line left afterwards.

If that works, it might be worth while checking what version of Java you are using.
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,

Per your suggestion I tried adding blank line to my Manifest file.
still stuck.

my java version-

C:\Users\abhagat\TRAINING\SCJD\dennysDVDs>java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

and i put verbose in my jar command.....

here is the output.
C:\Users\abhagat\TRAINING\SCJD\dennysDVDs>jar -cvfm sampleproject.jar Manifest.mf -C classes .
added manifest
adding: sampleproject/(in = 0) (out= 0)(stored 0%)
adding: sampleproject/db/(in = 0) (out= 0)(stored 0%)
adding: sampleproject/db/DBClient.class(in = 797) (out= 372)(deflated 53%)
adding: sampleproject/db/DosClient.class(in = 5033) (out= 2932)(deflated 41%)
adding: sampleproject/db/DVD.class(in = 4976) (out= 2220)(deflated 55%)
adding: sampleproject/db/DvdDataAccess.class(in = 680) (out= 332)(deflated 51%)
adding: sampleproject/db/DvdDatabase.class(in = 2166) (out= 967)(deflated 55%)
adding: sampleproject/db/DvdFileAccess$1RecordFieldReader.class(in = 892) (out=
544)(deflated 39%)
adding: sampleproject/db/DvdFileAccess$1RecordFieldWriter.class(in = 916) (out=
521)(deflated 43%)
AND LOT MORE......

and when i try to exceute, I still get the same error....

C:\Users\abhagat\TRAINING\SCJD\dennysDVDs>java -jar sampleproject.jar alone

Failed to load Main-Class manifest attribute from
sampleproject.jar

now what to do??
Regards,

Anu




 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

I created a simple HelloWorld.java program, and I put it in a test package. I am able to make executable jar and run it. So next thing I need to look at what am doing that it did not work when I work with dennysDVD project. A tiny progress....


 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

My Simple HelloWorld exceutable jar worked, but still have same propblem when I work with dennysDVD project.

 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Andrew, I threw away my old project and started from scratch. It is working now. I think I did everything same....so I have no clue what was the wrong....
I am sure there was a user error somwhere......

Thanks you for you massages and looking at this problem

Regards,

Anu
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad that worked for you.

My next step was going to get you to email your manifest file to me. All I can assume is that there was some character in it that the Jar tool did not like, and so it was ignoring the manifest.

Good luck with your SCJD.

Regards, Andrew
 
Anu Bhagat
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your wishes for SCJD.

Regards,

Anu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic