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

  • Thread starter Ramon F Herrera
  • Start date
R

Ramon F Herrera

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
 
A

Andrew Thompson

Ramon said:
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
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"

..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.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
R

Ramon F Herrera

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..


.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.


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
 
R

Ramon F Herrera

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
 
L

Lew

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

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
# 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.
 
E

Esmond Pitt

Andrew said:
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.
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top