469,304 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

SplashScreen.getSplashScreen returns null

myusernotyours
188 100+
Am trying to create a splash screen using the SplashScreen class.
i edit the manifest file to be put in to the jar file and also put the .gif file in the application directory but the method returns null all the time.
Should the .gif file be inside the jar and how do i get it there. Am using netbeans 6 and it automatically builds the jar.
Apr 4 '08 #1
7 9200
BigDaddyLH
1,216 Expert 1GB
In this article:

http://java.sun.com/developer/techni...res/index.html

It notes:

f your application is packaged in a JAR file, use the SplashScreen-Image option in a manifest file. Place the image in the JAR archive and specify the path in the option. For example, use this code in the manifest.mf file:
Manifest-Version: 1.0
Main-Class: SplashTest
SplashScreen-Image: filename.gif
You should put your image in the jar in the same want you put other resources in the jar. I don't know how netbeanz does this, I always do this by hand or with ant. This might help:

http://java.sun.com/docs/books/tutor...jar/index.html
Apr 4 '08 #2
myusernotyours
188 100+
Can someone then help with how to add files to the jar in netbeans. I have no idea how its done with ant or by hand. I am using netbeans for all my development.
Apr 5 '08 #3
myusernotyours
188 100+
In this article:

http://java.sun.com/developer/techni...res/index.html

It notes:

f your application is packaged in a JAR file, use the SplashScreen-Image option in a manifest file. Place the image in the JAR archive and specify the path in the option. For example, use this code in the manifest.mf file:
Manifest-Version: 1.0
Main-Class: SplashTest
SplashScreen-Image: filename.gif
You should put your image in the jar in the same want you put other resources in the jar. I don't know how netbeanz does this, I always do this by hand or with ant. This might help:

http://java.sun.com/docs/books/tutor...jar/index.html

Thanks
But I need to know how to do it in netbeans coz its what i use for all my development.

regards.
Apr 5 '08 #4
myusernotyours
188 100+
Now I managed to put the image in to the jar in netbeans - just put the image in the src folder and build, but the method still returns null. I also edit the manifest correctly. Any ideas?
Apr 7 '08 #5
pronerd
392 Expert 256MB
Now I managed to put the image in to the jar in netbeans - just put the image in the src folder and build, but the method still returns null. I also edit the manifest correctly. Any ideas?
Have you verified what path is being used to access the image? Either with your debugger, or a system.out.print call?
Apr 7 '08 #6
BigDaddyLH
1,216 Expert 1GB
Now I managed to put the image in to the jar in netbeans - just put the image in the src folder and build, but the method still returns null. I also edit the manifest correctly. Any ideas?
You have to realize that the path passed to the getResource method is a path.

If the class file and the image file are in the same "directory" in the jar you can write:
Expand|Select|Wrap|Line Numbers
  1. URL url = this.getClass().getResource("image.jpeg");
But suppose the class file is located in the jar in "/com/acme/widgets/Foo.class" and the image is in "/resources/pics/image.jpeg". In that case a "absolute" path in the jar makes more sense:
Expand|Select|Wrap|Line Numbers
  1. URL url = this.getClass().getResource("/resources/pics/image.jpeg");
I can't say more because you haven't given any details.

One more thing: paths in jars are case sensitive, even in Windows!
Apr 7 '08 #7
myusernotyours
188 100+
Thanks Guys, it works. But only when i click on the jar. On netbeans, it still returns null, can u think of a way to make it run from the ide?

Kind regards
Apr 8 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Rene van Hoek | last post: by
1 post views Thread by Suresh | last post: by
2 posts views Thread by Jeff Adams | last post: by
1 post views Thread by js | last post: by
6 posts views Thread by Peter Michaux | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.