Problem with JAR Files

Discussion in 'Java' started by Frank Wood, Apr 8, 2004.

  1. Frank Wood

    Frank Wood Guest

    I am developing a small front-end utilizing the AbsoluteLayout layout
    from the AbsoluteLayout.jar file (which contains AbsoluteLayout.class
    and AbsoluteConstraints.class), which comes from NetBeans 3.5.1.

    My file is named Tray.java. I compile this down to Tray.class. I can
    run this just fine from the command prompt with:

    java.exe -classpath "c:\program
    files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar";c:\tray
    Tray

    Of course, I can run it from the IDE in NetBeans as well with no
    problems. My problem is attempting to run it all as a JAR file. I
    create the jar file like (from the folder where the Tray*.class files
    are located) this:

    jar -cfm Tray.jar manifest.txt Tray*.class "c:\program
    Files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

    The manifest.txt file looks like this:

    Main-Class: Tray
    Class-Path: .;"c:\program
    files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

    Anyway, when I try to run the JAR file from the command prompt (as I
    sit in the folder where the Tray.jar file I just created resides):

    java -jar Tray.jar

    I get:

    C:\Tray>java -jar Tray.jar
    Exception in thread "main" java.lang.NoClassDefFoundError:
    org/netbeans/lib/awte
    xtra/AbsoluteLayout
    at Tray.initComponents(Tray.java:85)
    at Tray.<init>(Tray.java:15)
    at Tray.main(Tray.java:522)

    As you can probably tell, I'm fairly new at Java and have been able to
    hurdle a number of things so far - but this one I haven't been able to
    quite get over. I'm guessing that for whatever reason, it can't find
    the AbsoluteLayout class that I need for my program to run.

    Any help with this issue sure would be appreciated.

    Thanks,
    Frank Wood
     
    Frank Wood, Apr 8, 2004
    #1
    1. Advertising

  2. On 8 Apr 2004 12:08:00 -0700, Frank Wood wrote:

    > I am developing a small front-end
    > utilizing the AbsoluteLayout layout


    Is that an oxymoron? ;-)

    > ..which comes from NetBeans 3.5.1.


    Another reason I am suspicious of
    "advanced" D'n'D GUI designers.

    AbsoluteLayout, harumph!

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Apr 8, 2004
    #2
    1. Advertising

  3. Frank Wood

    Chris Smith Guest

    Frank Wood wrote:
    > The manifest.txt file looks like this:
    >
    > Main-Class: Tray
    > Class-Path: .;"c:\program
    > files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"


    Two things:

    1. The "Manifest-Version" attribute is REQUIRED in a JAR file manifest,
    and should be set to a value of "1.0". Many utilities will not properly
    read a manifest unless it has that attribute (aside from the general
    concern that it's illegal).

    2. The Class-Path attribute consists of a *whitespace* separated list of
    *relative* paths to JAR files *only*. You're using a semicolon-
    separated list of potentially absolute paths to some combination of JAR
    files and directories; hence the inability of the JRE to figure out what
    you're talking about.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Apr 8, 2004
    #3
  4. On Thu, 8 Apr 2004 14:04:16 -0600, Chris Smith wrote:

    > Frank Wood wrote:
    >> The manifest.txt file looks like this:
    >>
    >> Main-Class: Tray
    >> Class-Path: .;"c:\program
    >> files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

    ...
    > 1. The "Manifest-Version" attribute is REQUIRED in a JAR file manifest,
    > and should be set to a value of "1.0". Many utilities will not properly
    > read a manifest unless it has that attribute (aside from the general
    > concern that it's illegal).


    Let me get this straight, suppose this
    (*hypothetically*) were a manifest..

    Manifest-Version: 0.1
    Created-By: 1.0 PhySci.codes
    Main-Class: FindIt

    This would be _illegal_? Could you give
    me links/search terms to research it?

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Apr 8, 2004
    #4
  5. Frank Wood

    Chris Smith Guest

    Andrew Thompson wrote:
    > Let me get this straight, suppose this
    > (*hypothetically*) were a manifest..
    >
    > Manifest-Version: 0.1
    > Created-By: 1.0 PhySci.codes
    > Main-Class: FindIt
    >
    > This would be _illegal_? Could you give
    > me links/search terms to research it?


    Well, since there is no version 0.1 of the specification for JAR
    Manifest files, yes I'd say it would be! How would the parsing
    application know what expectations to make about the format of the
    remainder of the file?

    The manifest contents are defined at
    http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html... this defines
    that Manifest-Version is required, and all Manifest-Version attributes
    in that document are "1.0". I can't find a normative statement that the
    attribute *must* be set to 1.0; but why would you want to lie about what
    version of the spec you are following? The intent is clear enough that
    this should be set to a correct value.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Apr 8, 2004
    #5
  6. On Thu, 8 Apr 2004 15:14:45 -0600, Chris Smith wrote:

    > Andrew Thompson wrote:

    ....
    >> Manifest-Version: 0.1
    >> Created-By: 1.0 PhySci.codes
    >> Main-Class: FindIt

    ...
    > Well, since there is no version 0.1 of the specification for JAR
    > Manifest files, yes I'd say it would be! How would the parsing
    > application know what expectations to make about the format of the
    > remainder of the file?
    >
    > The manifest contents are defined at
    > http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html... this defines
    > that Manifest-Version is required, and all Manifest-Version attributes
    > in that document are "1.0". I can't find a normative statement that the
    > attribute *must* be set to 1.0;


    ...hmmm, looking at this..
    <http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest%20Specification>
    ...and, this..
    <http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Main%20Attributes>
    "Manifest-Version:
    Defines the manifest file version. The value is a legitimate
    version number, as described in the above spec"

    I'd say your right

    >..but why would you want to lie about what
    > version of the spec you are following?


    (*hypothetically*) Someone may wish to indicate
    a 'not-the-ridgy-didge' version in some (subtle)
    way, and choose that as the way, ..for instance.

    > The intent is clear enough that
    > this should be set to a correct value.


    Someone who created such a manifest programmatically
    might have some quick coding to do (*hypothetically*).

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Apr 8, 2004
    #6
  7. Frank Wood

    Chris Smith Guest

    Andrew Thompson wrote:
    > ..hmmm, looking at this..
    > <http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest%20Specification>
    > ..and, this..
    > <http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Main%20Attributes>
    > "Manifest-Version:
    > Defines the manifest file version. The value is a legitimate
    > version number, as described in the above spec"
    >
    > I'd say your right


    Actually, I interpret the phrase "is a legitimate version number, as
    described in the above spec" to refer to the grammar rules for the
    "version-number" production... so that doesn't yet prove that I'm right.
    On further reflection, to determine that I'm right, you have to look at
    a number of other sources that tell you specifically that the attribute
    called "Manifest-Version" refers to conformance to a version of the
    manifest spec; that's nowhere spelled out clearly in the spec itself.
    Then you have to work from example; the spec doesn't have a clear
    version number labeled anywhere, but all its examples contain a
    "Manifest-Version: 1.0", so that indirectly implies that 1.0 is a
    correct version.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Apr 9, 2004
    #7
  8. Frank Wood

    Roedy Green Guest

    On 8 Apr 2004 12:08:00 -0700, (Frank Wood) wrote or
    quoted :

    >I am developing a small front-end utilizing the AbsoluteLayout layout
    >from the AbsoluteLayout.jar file (which contains AbsoluteLayout.class
    >and AbsoluteConstraints.class), which comes from NetBeans 3.5.1.


    Another approach might be simpler. Unpack the classes you need and
    bundle them with your stuff all in one jar.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Apr 9, 2004
    #8
  9. Frank Wood

    Roedy Green Guest

    On 8 Apr 2004 12:08:00 -0700, (Frank Wood) wrote or
    quoted :

    >jar -cfm Tray.jar manifest.txt Tray*.class "c:\program
    >Files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"



    see http://mindprod.com/jgloss/jar.html#MAINCLASS

    the catch is you can't use absolute filenames, and you must use /
    instead of \ in the manifest. This is supposed to be platform
    independent.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Apr 9, 2004
    #9
  10. Frank Wood

    Frank Wood Guest

    Thanks for the help everyone--I was able to finally get it working on
    my PC. However, once I moved the JAR file to another PC, and attempted
    to run it, it failed.

    I open up the JAR file with WinZip and see NO path information (except
    for the manifest). In this JAR file, there is another JAR called
    "AbsoluteLayout.jar". If I then open up this JAR file, it contains two
    files (both class files), with a path of "org\netbeans\lib\awtextra".
    The manifest has a class-path setting of "AbsoluteLayout.jar", which
    of course, is there.

    There error, from the Java Console is:

    "java.lang.NoClassDefFoundError:eek:rg/netbeans/lib/awtextra/AbsoluteLayout"

    Any ideas what could be causing the problem?

    Thanks in advance for any help.

    -Frank








    Roedy Green <> wrote in message news:<>...
    > On 8 Apr 2004 12:08:00 -0700, (Frank Wood) wrote or
    > quoted :
    >
    > >jar -cfm Tray.jar manifest.txt Tray*.class "c:\program
    > >Files\j2sdk_nb\netbeans3.5.1\modules\ext\AbsoluteLayout.jar"

    >
    >
    > see http://mindprod.com/jgloss/jar.html#MAINCLASS
    >
    > the catch is you can't use absolute filenames, and you must use /
    > instead of \ in the manifest. This is supposed to be platform
    > independent.
     
    Frank Wood, Apr 21, 2004
    #10
  11. Frank Wood <> wrote:
    > Thanks for the help everyone--I was able to finally get it working on
    > my PC. However, once I moved the JAR file to another PC, and attempted
    > to run it, it failed.


    I use AbsoluteLayout. I just include
    org/netbeans/lib/awtextra/AbsoluteConstraints.class and
    org/netbeans/lib/awtextra/AbsoluteLayout.class in my Jar files and things
    work just fine.

    Of course, I cheat. :) I create a JAR recipe from the IDE... since I'm
    working in the IDE anyhow.

    ;P to those people who claimed this is a problem with AbsoluteLayout and
    say that AbsoluteLayout sucks.

    --
    JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED
    Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) /
    Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/
    "someone once called me a sofa, but i didn't feel compelled to rush out and buy
    slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003
     
    Steven J Sobol, Apr 21, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric McIntyre

    Jar files in Jar files

    Eric McIntyre, May 24, 2004, in forum: Java
    Replies:
    1
    Views:
    495
    Roedy Green
    May 24, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    613
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,767
    muttley
    Oct 20, 2005
  4. cyberco
    Replies:
    4
    Views:
    3,846
    Roedy Green
    Feb 14, 2006
  5. Arnold Peters
    Replies:
    0
    Views:
    689
    Arnold Peters
    Jan 5, 2005
Loading...

Share This Page