SplashScreen-Image and Libraries

J

Jason Cavett

I am trying to use the SplashScreen feature in Java 6, and it works
when I use the -splash parameter passed to the JVM. However, when I
try to use the MANIFEST file, it doesn't seem to work correctly. I
think this has to do with the fact that the image I am trying to
access is within another directory (it's specifically in a library
that has been included in the project's classpath). Here is my
MANIFEST file:

Manifest-Version: 1.0
Main-Class: myproject.Main
SplashScreen-Image: "resources/icons/misc_icons/Title Screen.png"
Class-Path: lib/Project_Resources.jar

resources/icons/misc_icons/Title Screen.png is found within the
Project_Resources.jar. I have tried moving the Class-Path variable
before SplashScreen-Image but that does not seem to help the problem.

Does anybody have any suggestions? Thanks
 
K

Knute Johnson

Jason said:
I am trying to use the SplashScreen feature in Java 6, and it works
when I use the -splash parameter passed to the JVM. However, when I
try to use the MANIFEST file, it doesn't seem to work correctly. I
think this has to do with the fact that the image I am trying to
access is within another directory (it's specifically in a library
that has been included in the project's classpath). Here is my
MANIFEST file:

Manifest-Version: 1.0
Main-Class: myproject.Main
SplashScreen-Image: "resources/icons/misc_icons/Title Screen.png"
Class-Path: lib/Project_Resources.jar

resources/icons/misc_icons/Title Screen.png is found within the
Project_Resources.jar. I have tried moving the Class-Path variable
before SplashScreen-Image but that does not seem to help the problem.

Does anybody have any suggestions? Thanks

How can you have a Class-Path: of lib/Project_Resources.jar? Is lib in
the project jar? I don't think you can do that. Of course I could be
totally confused :).
 
J

Jason Cavett

How can you have a Class-Path: of lib/Project_Resources.jar? Is lib in
the project jar? I don't think you can do that. Of course I could be
totally confused :).

Ah, yes.../lib is contained within the project JAR. Something like
this...

Project.jar
- compiled.code.packages.and.stuff
- lib
- Project_Resources.jar

There is a configuration file, as well as a C++ launcher to read that
configuration file outside of the Project.jar. The C++ launcher was
created so a splash screen could be shown, but now that Java does it,
I think I can get rid of the C++ launcher if I can figure out this
problem.
 
L

Lew

The manifest Class-Path entry refers to a JAR on the local (i.e., deployment)
platform, not within the JAR whose manifest this is. In other words, the
referenced JAR is external to the referencing JAR.

Jason said:
Ah, yes.../lib is contained within the project JAR.

The manifest file's Class-Path entry does not refer to directories within the JAR.
 
O

Owen Jacobson

Ah, yes.../lib is contained within the project JAR. Something like
this...

Project.jar
- compiled.code.packages.and.stuff
- lib
- Project_Resources.jar

There is a configuration file, as well as a C++ launcher to read that
configuration file outside of the Project.jar. The C++ launcher was
created so a splash screen could be shown, but now that Java does it,
I think I can get rid of the C++ launcher if I can figure out this
problem.

The built-in classloaders in general can't look inside JARs that are
inside JARs. Your Class-Path attribute instead specifies
Project_Resources.jar in the directory lib in the same directory the
Project.jar is in, like so:

foo/
foo/Project.jar
foo/lib/
foo/lib/Project_Resources.jar

It's not terribly hard to write your own classloader that can look
inside a JAR for JARs, but it won't be availalble until after the
splashscreen-displaying code in the JRE has already run. You'll have
to restructure your packaging to use the built-in splash screen.

-O
 
J

Jason Cavett

The manifest Class-Path entry refers to a JAR on the local (i.e., deployment)
platform, not within the JAR whose manifest this is. In other words, the
referenced JAR is external to the referencing JAR.



The manifest file's Class-Path entry does not refer to directories within the JAR.

Wow. I can't believe I made that beginner mistake (already knew that
too - /lib/Project_Resources.jar exists outside my Project.jar).

Anyway, it seems like from Owen's response, there's no way for the
classloader to know about files in other JARs, so I have to put the
splashscreen image within my main JAR file.

Alright, thanks for the help everybody.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top