SplashScreen.getSplashScreen returns null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • myusernotyours
    New Member
    • Nov 2007
    • 188

    #1

    SplashScreen.getSplashScreen returns null

    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.
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    In this article:



    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:

    This deployment Java tutorial describes development and deployment of applets, Java Web Start applications, rich Internet applications, and JAR related tools

    Comment

    • myusernotyours
      New Member
      • Nov 2007
      • 188

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

      Comment

      • myusernotyours
        New Member
        • Nov 2007
        • 188

        #4
        Originally posted by BigDaddyLH
        In this article:



        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.

        Comment

        • myusernotyours
          New Member
          • Nov 2007
          • 188

          #5
          Still cant get the splash screen to show! Help.

          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?

          Comment

          • pronerd
            Recognized Expert Contributor
            • Nov 2006
            • 392

            #6
            Originally posted by myusernotyours
            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.prin t call?

            Comment

            • BigDaddyLH
              Recognized Expert Top Contributor
              • Dec 2007
              • 1216

              #7
              Originally posted by myusernotyours
              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:
              [CODE=Java]URL url = this.getClass() .getResource("i mage.jpeg");[/CODE]
              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:
              [CODE=Java]URL url = this.getClass() .getResource("/resources/pics/image.jpeg");[/CODE]
              I can't say more because you haven't given any details.

              One more thing: paths in jars are case sensitive, even in Windows!

              Comment

              • myusernotyours
                New Member
                • Nov 2007
                • 188

                #8
                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

                Comment

                Working...