Problem in accessing resources from jar file

hello,

i am new to jar concept so plz help me . I have created an applet which contains sounds and images. and now i am creating a jar file which contains all the sounds and images and class files required for applet now the problem i am getting is:

1. my jar file size ranges in MBs which is making my applet download time longer.

so tell me what should i do to reduce the download time

2. i want to keep my class files in jar only then please tell me where do i put my images and sound file and how do i'll access them .

Thanx

[569 byte] By [1softsolutionsa] at [2007-11-27 6:49:49]
# 1

> . my jar file size ranges in MBs which is making my

> applet download time longer.

> so tell me what should i do to reduce the download

> time

> . i want to keep my class files in jar only then

> please tell me where do i put my images and sound

> file and how do i'll access them .

>

> Thanx

You can keep them on the server and use methods like getImage() and getAudioClip() to access them.The applet will download them when it needs them. Note, however, that an applet is only allowed to connect back to the server it was downloaded from.

http://java.sun.com/j2se/1.5.0/docs/api/java/applet/Applet.html#getAudioClip(java.net.URL)

http://java.sun.com/j2se/1.5.0/docs/api/java/applet/Applet.html#getImage(java.net.URL)

kevjavaa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...
# 2
u can use JNLP or video streaming for substitute.
BMPRASADa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...
# 3

I am accessing images and sound files using getImage and getAudioClip but every time i access it without a jar file it will make as many HTTP connections and i want to have only 1 HTTP connection to access a jar file only.

and also i want to reduce the size of my jar file. Plz suggest something for that

1softsolutionsa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...
# 4
I donot have any idea of JNLP. can you plz tell me something about it in detail.....Thanx
1softsolutionsa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...
# 5

> I am accessing images and sound files using getImage

> and getAudioClip but every time i access it without a

> jar file it will make as many HTTP connections and i

> want to have only 1 HTTP connection to access a jar

> file only.

>

> and also i want to reduce the size of my jar file.

> Plz suggest something for that

If you want to make one HTTP connection, then bundle everything in one .jar file, and make calls to Class.getResource() and Class.getResourceAsStream(). That way, all the files will already be downloaded.

As for JNLP, it's a way to do the Java WebStart thing. You have to package everything up the same way, and you wouldn't get any more benefits than by just packing it up in one jar file. It's useless for an applet.

kevjavaa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...
# 6

>>If you want to make one HTTP connection, then bundle everything in >>one .jar file, and make calls to Class.getResource() and >>Class.getResourceAsStream(). That way, all the files will already be >>downloaded.

I have done the same thing but everytime i am making a call to image it makes shows tha output in console window like this ::

jar:file:http://servername/my.jar!/redchips.png

why is that so ?

Thanx

1softsolutionsa at 2007-7-12 18:23:38 > top of Java-index,Java Essentials,New To Java...