• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help with jar utility

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.cs.princeton.edu/introcs/85application/jar/jar.html
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic