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

  • Thread starter =?iso-8859-1?B?UulnaXMgROljYW1wcw==?=
  • Start date
?

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

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,
 
L

Lew

Régis Décamps said:
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.
 
?

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

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

Thanks for the confirmation.

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"?
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
 
L

Lew

Régis Décamps said:
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.
 
A

Almond

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top