Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Régis Décamps - 29 Oct 2007 10:41 GMT
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
Lew - 29 Oct 2007 15:06 GMT
> 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/
[quoted text clipped - 3 lines]
>
> 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.

Signature

Lew

Régis Décamps - 30 Oct 2007 17:02 GMT
> > 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/
[quoted text clipped - 6 lines]
> 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
Lew - 31 Oct 2007 01:19 GMT
> 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.

Signature

Lew

Almond - 31 Oct 2007 06:16 GMT
>Régis Décamps wrote:
>> That's the normal approach for a resource bundle. But mine is rather a
[quoted text clipped - 6 lines]
>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.

Signature

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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.