But beware that reading "pom.properties" might expose similar problem
as soon as there is a second jar (or some classes directory) with such file (name).

This is intrinsic to anything that uses getResource*() family of methods (at least under the hood) A dirty hack for avoiding that trouble would be to use a file name that likely is unique to your application.

Rainer

On 11.01.2012 22:13, Steve Cohen wrote:
Thanks for explaining this mysterious result.
I have found that using the pom.properties that Maven creates is a more straightforward approach and also can be made to work when the program is not run from the jar (i.e., from Eclipse).

Thanks.

On 01/11/2012 02:30 PM, Rainer Pruy wrote:
Looks like there are other jar (or classes directories) in classpath.

getRessourceAsStream() will access the first entry (according to current
classloader logic)
and this need not be the one from the jar you are interested in.
You might use getRessources() to get all candidates enumerated.
(This was what lead me to get an URL from a class that resides with the
same jar and explicitly read that file as outlined in my previous reply)

Rainer

On 11.01.2012 20:41, Steve Cohen wrote:
On 01/11/2012 12:14 PM, Wayne Fay wrote:
getResourceAsStream("META_INF/MANIFEST.MF") and
getResourceAsStream("/META_INF/MANIFEST.MF") without success even
though
I've verified that the file exists in the jar,

Uhh that should be META-INF, right?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org



Duh - that's it.

However -- fixing that the code now sees the manifest. However, the
manifest it sees is not the one that I see when looking at the file in
the jar with WinZip.

Here is META-INF/MANIFEST.MF in the jar:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_23
Built-By: Steve
Implementation-Title: MyApp
Implementation-Version: 0.6.1-SNAPSHOT
Implementation-Vendor-Id: com.whatever
Main-Class: com.whatever.Main
SplashScreen-Image: SplashScreen.jpg

Yet when my app reads the manifest
( getResourceAsStream("META_INF/MANIFEST.MF" )
and then iterates through the manifest attributes, it sees this:

Manifest-Version : 1.0
Created-By : 1.4.2 (IBM Corporation)

If I specify instead
getResourceAsStream("/META_INF/MANIFEST.MF") then the file is not found.

I can't make any sense of these symptoms. Manifests are just too
weird, it seems.

Unless someone can explain this weirdness, I'll try the approach with
maven.properties.






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to