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 / December 2007

Tip: Looking for answers? Try searching our database.

Is this a valid Manifest? + Fully qualified vs. relative paths

Thread view: 
Ramon F Herrera - 09 Dec 2007 04:35 GMT
Is this a valid Manifest?

Manifest-Version: 1.0
Main-Class: openoffice.DocumentSaver
Class-Path: "C:/Program Files/OpenOffice.org 2.3/program/classes/
juh.jar" "C:/Program Files/OpenOffice.org 2.3/program/classes/
jurt.jar" "C:/Program Files/OpenOffice.org 2.3/program/classes/
ridl.jar" "C:/Program Files/OpenOffice.org 2.3/program/classes/
unoil.jar"

Another question(s)...

IIRC, all the examples that I have seen use fully qualified paths for:

java -classpath C:\somedir\mylibs.jar -jar program.jar

or for

set CLASSPATH=C:\somedir\mylibs.jar
java -jar program.jar

and they use relative paths inside the manifest.

Is that the case? Do I have to use fully qualified at the CLI and
relative inside the manifest?

Can I mix forward slashes with back slashes?

All tutorial writers, of course, avoid the non-trivial detail of
Windows paths having spaces and use simplistic cases with no spaces.

-Ramon
Andrew Thompson - 09 Dec 2007 04:55 GMT
>Is this a valid Manifest?

In some respects it is hard to say, since dumping the content
to a usenet message does not inherently tell us if the manifest
ends with a single blank line.  But..

>Manifest-Version: 1.0
>Main-Class: openoffice.DocumentSaver
[quoted text clipped - 3 lines]
>ridl.jar" "C:/Program Files/OpenOffice.org 2.3/program/classes/
>unoil.jar"

..I heard the other day that manifest lines need to be no
longer than 72 chars, and that last one sure looks longer.

Also, it is exceedingly fragile to specify complete paths
to jars in the classpath.  It would be better to place the
extension jars in a place where they can be referred to be
relative paths.

Signature

Andrew Thompson
http://www.physci.org/

Ramon F Herrera - 09 Dec 2007 05:19 GMT
> >Is this a valid Manifest?
>
[quoted text clipped - 22 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1

Hi Andrew:

I am just reviewing the different ways of doing things. It's a self-
imposed homework, to test the tricky things like paths with spaces.
(BTW: Windows sucks).

NetBeans writes a nice Manifest for me:

Class-Path: lib/juh.jar lib/jurt.jar lib/ridl.jar lib/unoil.jar

I have (unfortunately) been using DOS and its descendants since '81
and now I realize that a so-called "Shortcut" is not quite the same as
a soft link, since it works from the GUI only.

The class path above expects all the jars to be inside the directory
'lib', but in real life, the original files are inside a subdirectory
called program/classes. This detail is easy to solve, right? Just make
a shortcut called "Program_Files", another one called
"OpenOffice.org_2.3" and one called "lib" that points to "classes".
All Windows developers out there (except me, until now) know that you
cannot see those "directories" from the Command Prompt.

In short: I am just testing the waters of DOS-land, as I have always
been a chicken, programming and running from inside JBuilder, NetBeans
and Eclipse. Now, I have to bite the bullet (and I don't like what I
am tasting) of this INNOVAT~1 O.S.

Thanks...

-Ramon
Lew - 09 Dec 2007 06:19 GMT
"Andrew Thompson" wrote:
>> Also, it is exceedingly fragile to specify complete paths
>> to jars in the classpath.  It would be better to place the
>> extension jars in a place where they can be referred to be
>> relative paths.

> I am just reviewing the different ways of doing things. It's a self-
> imposed homework, to test the tricky things like paths with spaces.
[quoted text clipped - 9 lines]
>
> The class path above expects all the jars to be inside the directory 'lib',

relative to where the JAR is installed

> but in real life, the original files are inside a subdirectory called program/classes.

Relative to where the JAR is deployed?  If so, you could put that in the manifest.

> This detail is easy to solve, right? Just make
> a shortcut called "Program_Files", another one called
> "OpenOffice.org_2.3" and one called "lib" that points to "classes".

I don't know what this all means.

> All Windows developers out there (except me, until now) know that you
> cannot see those "directories" from the Command Prompt.

Seeing directories from the command prompt isn't really the point.  The point
is that the JAR containing your application is in a directory.  ("Program
Files" is probably not the best choice, since a JAR isn't actually a program.)
 Anyway, the manifest directories are relative to the directory in which the
JAR is deployed.

The problem with absolute paths is that they might not exist on every platform
to which the JAR is deployed.  What if you say "C:\blahdiddyblah\blah" then
deploy to a UNIX machine?

I also strongly suggest you stay away from ../whatever (relative parent
directory) paths - again, it's hard to guarantee that they'll exist everywhere
you deploy your JAR.  Subdirectories are easier to ensure.

Forward slashes are the way to go in a manifest, or really any time.  Windows
recognizes forward slashes.  It looks like they're actually required, judging
from
<http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest>
which states
> # Class-Path :
>
> 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.

URLs need forward slashes.  Note also the specifciation of _relative_ URLs.

NetBeans also usually creates a dist/ directory, doesn't it?  Wherever it
places the JAR you build, it's /supposed/ to create a subdirectory for
requisite JARs, by default lib/ relative to the JAR location.  I have heard
there might be a bug with respect to this with application JARs, although it
works just fine for the WEB-INF/lib/ subdirectory of web applications.

Signature

Lew

Ramon F Herrera - 09 Dec 2007 05:31 GMT
> >Is this a valid Manifest?
>
> In some respects it is hard to say, since dumping the content
> to a usenet message does not inherently tell us if the manifest
> ends with a single blank line.  But..

Are you sure about that? I was just reading the Wikipedia article on
Class Loaders and this is what it says on the so-called "empty line"
issue:

"Note: It's important that the manifest file ends with either a new
line or carriage return".
   http://en.wikipedia.org/wiki/Classpath

Your claim seems to be that the manifest must end with *two* line
terminators, but Wikipedia says that it has to be one.

I suspect the problem is that Windows editors allow you to type the
last line without its line terminator, but Un*x editors will never do
that. So, what the Java designers are telling people is: "don't forget
to press <ENTER> after the last line" which is not the same as "leave
an empty line at the end". Of course, the second interpretation is
like wearing belt and suspenders.

-Ramon
Esmond Pitt - 09 Dec 2007 23:52 GMT
>>Is this a valid Manifest?
>
> Also, it is exceedingly fragile to specify complete paths
> to jars in the classpath.

It's not just 'exceedingly fragile', it's illegal. Classpaths in the
manifest are relative to where the containing JAR is located.

So no, it's not a legal manifest.


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.