Specify a directory in the Class-Path entry of the Manifest

Discussion in 'Java' started by =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=, Oct 29, 2007.

  1. Hi,

    I am building a simple Java application packaged as a JAR.

    The application relies on some libraries that are referenced in the
    JAR Manifest entry, like this:
    Class-Path: lib/webservices-api.jar lib/webservices-extra-api.jar lib/
    webservices-extra.jar lib/webservices-rt.jar lib/webservices-tools.ja
    r lib/junit-3.8.1.jar

    Now, I'd like the application to read a property file with
    ResourceBundle.getBundle().

    It works pretty well if I change the Class-Path entry like this
    Class-Path: lib/webservices-api.jar lib/webservices-extra-api.jar lib/
    webservices-extra.jar lib/webservices-rt.jar lib/webservices-tools.ja
    r lib/junit-3.8.1.jar .
    (note the "." at the end)

    But I wonder if it is "legal". The specs only say (http://java.sun.com/
    javase/6/docs/technotes/guides/jar/jar.html)
    "The value of this attribute specifies the relative URLs of the
    extensions or libraries that this application or extension needs. URLs
    are separated by one or more spaces. The application or extension
    class loader uses the value of this attribute to construct its
    internal search path. "

    Extra questions: how to change the Netbeans project to add this "." in
    the generated manifest?

    Thanks,
    --
    Régis
     
    =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=, Oct 29, 2007
    #1
    1. Advertising

  2. =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=

    Lew Guest

    Régis Décamps wrote:
    > It works pretty well if I change the Class-Path entry like this
    > Class-Path: lib/webservices-api.jar lib/webservices-extra-api.jar lib/
    > webservices-extra.jar lib/webservices-rt.jar lib/webservices-tools.ja
    > r lib/junit-3.8.1.jar .
    > (note the "." at the end)
    >
    > But I wonder if it is "legal".


    Why put "legal" in quotes? The answer is that it is legal, as shown by the
    passage that you quote:

    > The specs only say (<http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html>)
    > "The value of this attribute specifies the relative URLs of the
    > extensions or libraries that this application or extension needs. URLs
    > are separated by one or more spaces. The application or extension
    > class loader uses the value of this attribute to construct its
    > internal search path. "


    And that answers your question completely.

    > Extra questions: how to change the Netbeans project to add this "." in
    > the generated manifest?


    There really doesn't seem to be an automatic way.

    Maybe you can create a META-INF/MANIFEST.MF file and just edit it directly.

    The normal approach would be just to put the bundle in the JAR, where it's
    already in the classpath.

    --
    Lew
     
    Lew, Oct 29, 2007
    #2
    1. Advertising

  3. On 29 oct, 15:06, Lew <> wrote:
    > Régis Décamps wrote:
    > > It works pretty well if I change the Class-Path entry like this
    > > Class-Path: lib/webservices-api.jar lib/webservices-extra-api.jar lib/
    > > webservices-extra.jar lib/webservices-rt.jar lib/webservices-tools.ja
    > > r lib/junit-3.8.1.jar .
    > > (note the "." at the end)

    >
    > > But I wonder if it is "legal".

    >
    > Why put "legal" in quotes? The answer is that it is legal, as shown by the
    > passage that you quote:


    Thanks for the confirmation.

    >
    > > The specs only say (<http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html>)
    > > "The value of this attribute specifies the relative URLs of the
    > > extensions or libraries that this application or extension needs.


    Actually, I thought this passage proved the contrary (sorry, but
    English is not my native language).
    * I thought an extension is an optional package used by an applet,
    such as java3d
    * I though a library was always packaged as a jar, such as lib/
    webservices-rt.jar
    As such, I thought "." was "illegal" in Class-Path (and the examples
    provided by Sun are only made of JARs
    http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html)

    However, I'm sure"." can be added in the classpath. At least, the
    classpath option from the java command (http://java.sun.com/j2se/1.3/
    docs/tooldocs/win32/classpath.html). That's why I originally tried to
    add "." to the Class-Path entry in the manifest.


    > And that answers your question completely.


    Hmmm, just for my information, is the directory "." considered as an
    "extension" or as a "library"?

    > > Extra questions: how to change the Netbeans project to add this "." in
    > > the generated manifest?

    >
    > There really doesn't seem to be an automatic way.
    >
    > Maybe you can create a META-INF/MANIFEST.MF file and just edit it directly.


    Yes, this can be done, indeed.

    > The normal approach would be just to put the bundle in the JAR, where it's
    > already in the classpath.


    That's the normal approach for a resource bundle. But mine is rather a
    configuration file, and I find unintuitive to change the configuration
    from within the Jar.

    Thanks
    --
    Régis
     
    =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=, Oct 30, 2007
    #3
  4. =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=

    Lew Guest

    Régis Décamps wrote:
    > That's the normal approach for a resource bundle. But mine is rather a
    > configuration file, and I find unintuitive to change the configuration
    > from within the Jar.


    This is an ongoing issue with app deployment - you put the config files in the
    JAR, but you have to modify them in the field. The only reliable answer I've
    seen so far is to have the sysadmin for the production environment manually
    configure the app as part of the deployment process; actually alter the
    unpacked config file(s).

    I would love to hear of a better solution.

    --
    Lew
     
    Lew, Oct 31, 2007
    #4
  5. =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=

    Almond Guest

    In article <>, Lew <> wrote:
    >Régis Décamps wrote:
    >> That's the normal approach for a resource bundle. But mine is rather a
    >> configuration file, and I find unintuitive to change the configuration
    >> from within the Jar.

    >
    >This is an ongoing issue with app deployment - you put the config files in the
    >JAR, but you have to modify them in the field. The only reliable answer I've
    >seen so far is to have the sysadmin for the production environment manually
    >configure the app as part of the deployment process; actually alter the
    >unpacked config file(s).


    Blah, blah, blah.

    You suck everywhere, right?

    >I would love to hear of a better solution.
    >


    --
    The most powerful Usenet tool you have ever heard of.
    NewsMaestro v. 4.0.5 - Way Too Cool has been released.

    Automatic enablement of all buttons, checkboxes and fields
    depending on operation.
    Templates generator improvements.

    Job list improvements for new installations having no jobs
    to begin with.

    In some previous releases some class files were missing.
    As a result, the program would not run.
    Sorry for the inconvenience.

    Multi-job support and other important feature additions
    and various improvements and optimizations.

    Web page:
    http://newsmaestro.sourceforge.net/

    Download page:
    http://newsmaestro.sourceforge.net/Download_Information.htm

    Send any feedback to newsmaestroinfo \at/ mail.ru.
    Your personal info will not be released and your privacy
    will be honored.
     
    Almond, Oct 31, 2007
    #5
    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. Juergen Weber

    Ant generating Classpath manifest entry

    Juergen Weber, Nov 4, 2003, in forum: Java
    Replies:
    0
    Views:
    2,481
    Juergen Weber
    Nov 4, 2003
  2. hiwa
    Replies:
    3
    Views:
    8,457
    John C. Bollinger
    Jan 15, 2004
  3. Replies:
    1
    Views:
    2,387
  4. Replies:
    10
    Views:
    3,674
  5. Cameron McCormack
    Replies:
    0
    Views:
    374
    Cameron McCormack
    Aug 27, 2007
Loading...

Share This Page