• 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

executable Jars

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok this is driving me nuts I keep on getting "failed to load Main-Class attribute from Viewer.jar"

I have a typical package directory set up com.yadda.something.else and com.another.something and then I have another.jar

I run jar -cmf Viewer.mf Viewer.jar *.*

and inside Viewer.mf I have:
Class-Path: Viewer.jar
Main-Class: com.yadda.something.else.View

I've also tried chaning main-class to: com/yadda/something/else/View

Both times I get the same error.

Anyone know what I'm doing wrong?

-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I guess a good starting point would be...

Whats the difference between "Failed to load Main-Class manifest attribute from C:\jartest\Viewer.jar"

and

Could not find the main class. Program will exit

?

is one error closer to the "right path" than the other?
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I tried removing the reference to the external jar and it works fine.

I would like to use the plastic3DLookAndFeel from JGoodies, but I don't know how to include it in the jar. I was just keeping the jar in the directory that I was creating my jar in. it was getting included but for some reason I still can't call the classes in it from my class.

-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok well I got around the problem by unpacking the external jar and adding it to the package structure I was putting into the jar.

Still I think it would be nice if instead of saying couldn't find main class it would tell you what exception was being thrown.

-Tad
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to have come to a solution on your own, but did you try changing the order of the attributes -- first Main-Class, and then Class-Path?
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I tried playing around with the order. I'm not sure it mattered much. I guess I just don't fully grasp how to specify the proper classpath so that jars inside of jars are accessed properly or how to get classes inside of the jar to properly reference/use classes inside of external jars.

-Tad

PS I guess the thing that irritated me the most was the cryptic error messages recieved when trying to run the jar. They didn't do much to help pinpoint the issue. And the code causing the problem was:
[code]
try
{
javax.swing.UIManager.setLookAndFeel(new com.jgoodies.plaf.plastic.Plastic3DLookAndFeel());
}
catch(Exception e ){}
[code]

I would think that if it couldn't find the class it would merely throw an exception and startup anyways using the default look and feel. Instead it threw an error saying it couldn't load the main class.

Seems counter intuitive to me.
[ March 18, 2005: Message edited by: Tad Dicks ]
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are miss-interpreting the error message. If I read you right you tried:
jar -cmf ...
which would be the command to create a jar file, not run one.

java -jar would be the command to run a jar file.

The Main-Class attribute does have to come before the Class-Path attribute in the manifest file. Also there must be an empty line after the Class-Path attribute.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic