This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with jar utility

 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
my application main class directory is as follow:
suncertify/bin/Runme.class

and suncertify directory is in a folder called dev
I am try to jar succertify, and updating the manifest so that the application can run using the command

java -jar runme.jar

I am using the following command to jar my files:
C:\dev>jar cf class-name suncertify/bin/Runme.class runme.jar suncertify*

it produces the jar file, however when I run it I get this error:
C:\dev>java -jar runme.jar
Failed to load Main-Class manifest attribute from
runme.jar

Am I missing a flag or something?
I am running JDK 1.4.2_4

can someone help please.
Like what you can tell, I am wrapping this application up, and I should take the test exam early next week.
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.cs.princeton.edu/introcs/85application/jar/jar.html
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hanna,

As shown in the link provided by Denis (good link Denis, it is now in our Reading Materials FAQ), you must create a manifest which describes which class is the class to run.

Regards, Andrew
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Denise and Andrew:
Thanks for the helpful link. I couldn't get it to work though.
I created the manifes.mf file. which contains

Manifest-Version: 1.0
Main-Class: Runme

my directory structure is:
suncertify>bin //has all classes
suncertify>code //has the source files
suncertify>manifest.mf // the manifest file

C:\dev>jar cmf suncertify/manifest.mf runme.jar suncertify*

when I run it I got class not found error.
C:\dev>java -jar runme.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Runme

Runme.class is in the default package:
suncertify/code/Runme.java
suncertify/bin/Runme.class

It works fine only if I generate the jar file from the directory where the Runme.class is located.

any clue what is going on here.
thanks
[ June 08, 2004: Message edited by: Hanna Habashy ]
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I created the manifes.mf file. which contains
Manifest-Version: 1.0
Main-Class: Runme

my directory structure is:
suncertify>bin //has all classes
suncertify>code //has the source files
suncertify>manifest.mf // the manifest file

C:\dev>jar cmf suncertify/manifest.mf runme.jar suncertify*

when I run it I got class not found error.
C:\dev>java -jar runme.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Runme

Runme.class is in the default package:
suncertify/code/Runme.java
suncertify/bin/Runme.class


Hanna, first of all, do you have to include source files into executable jar? I dont know about B&S, but in URLyBird it is required to include only code.
As to packaging, I will simply explain how I did and you'll see whats the problem:
1. I have such file structure:
suncertify
|____ db___ files
|____client___files / contains file Start.class
|____server___ files
2. In root folder (one which contains suncertify) i placed mf.mf:

Manifest-Version: 1.0
Main-Class: suncertify.client.Start // <--- full path

3. Then I type:

$ jar cmf mf.mf runme.jar suncertify

4. Now java -jar runme.jar must work.

[ June 09, 2004: Message edited by: Denis Spirin ]
[ June 09, 2004: Message edited by: Denis Spirin ]
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Denis:
My instruction states:

When you submit your assignment, each part (client and server) must be executable using a command of this exact form:

java -jar <path_and_filename> [<mode>]

I understand form that I must have an executable jar.
My instruction doesn't state anything about .class files, but how can I execute the jar without calss files? Also, how about stubs , I genereate the stubs using rmic compiler, and I leave in the bin directory.

I tried to add the full path of the main class file, and it didn't work.
I tried to add the class name in the manifest using:
Name: suncertify.bin.Runme.class
and still didn't work.
It works only if I generate the jar file while I am in the bin directory, I don't know what else to do.
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand form that I must have an executable jar.
My instruction doesn't state anything about .class files, but how can I execute the jar without calss files? Also, how about stubs , I genereate the stubs using rmic compiler, and I leave in the bin directory.

Your jar must include only .class files (not source files) and stub(s)/skeleton(s).

I tried to add the full path of the main class file, and it didn't work.
I tried to add the class name in the manifest using:
Name: suncertify.bin.Runme.class
and still didn't work.
It works only if I generate the jar file while I am in the bin directory, I don't know what else to do.

Check out all your steps again. Name must not include ".class", it should look like "suncertify.bin.Runme".
Are your files in corresponding packages (suncertify.bin etc)? Check if mf file is in plain text format.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Denis:
It is all my fault. I didn't understand the requirent corrctly. It states that the deliverabal is a jar file containting the excutable jar file. All the time I thought it would be one single jar contains all the project elements.
I have been working on my project constantly for the last week, my brain needs some oil.
Thank again for all your time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic