Skip to main content

Classpathextension

8 replies [Last post]
bloomfield
Offline
Joined: 2008-01-28

Hello all,

I've got a problem with my application which uses a large number of pictures.
The jar file which contains the main Xlet, gets too big (>4mb) when i put all pictures i need into it. Now i want to use a secondary jar (00002.jar), which contains all the images, i could not put into the first jar file. In my special case, the second jar file gets downloaded into the buda and integrated into vfs, which all seems to work.
Now i've tried to add this second jar to the classpath of the main Xlet by changing the classpathextension element belonging to my main Xlet (00001.jar) in the bdjo:
heres an excerpt:
...

00001
TITLE_BOUND_DISC_BOUND
/00002
1
...

Within the second jar 00002.jar, there's a folder calles "images".
So i try to acces the images by calling.
Image img = Toolkit.getDefaultToolkit().getImage("./images/image.png");
I also tried:
Image img = Toolkit.getDefaultToolkit().getImage("./00002/images/image.png");

It doesn't work.
Did anyone have success with this? I don't know what i forgot or what I am doing wrong.

Cheers
bloomfield

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bloomfield
Offline
Joined: 2008-01-28

Hello again,

do you know if it is possible to have 2 or more jars mounted via DSM-CC at the same time?

Cheers
Jan

Bill Foote

Hi Denny,

An assets file doesn't need to be in the classpath. It just
needs to be somewhere in the filesystem where you can access it
from Java.

For example, the HD cookbook's menu app mounts the filesystem
using the "DSMCC" API from MHP. Since you're putting it in the
BUDA, and presumably your app is signed and can read files from
the BUDA, you don't even need to do that; you just need to load
the image from the file directly, using the absolute pathname of
the file (and not the relative path name).

You don't even need to do the VFS update - just read it off the
BUDA filesystem, and access it from there.

By the way, you might look into putting the image files directly
on the disc, rather than putting them inside a JAR file. If you're
reading them straight off the optical filesystem (and not mounting
a filesystem using the DSMCC API), I can't think of an advantage to
putting them in a JAR. Indeed, I'd expect it would add overhead.

Bill
--
Bill Foote bill.foote @ sun.com
Blu-ray Java and Authoring Architect Sun Microsystems, Los Angeles

bd-j-dev@mobileandembedded.org wrote:
> Hello all,
>
> I've got a problem with my application which uses a large number of pictures.
> The jar file which contains the main Xlet, gets too big (>4mb) when i put all pictures i need into it. Now i want to use a secondary jar (00002.jar), which contains all the images, i could not put into the first jar file. In my special case, the second jar file gets downloaded into the buda and integrated into vfs, which all seems to work.
> Now i've tried to add this second jar to the classpath of the main Xlet by changing the classpathextension element belonging to my main Xlet (00001.jar) in the bdjo:
> heres an excerpt:
> ...
>
>
> 00001
> TITLE_BOUND_DISC_BOUND
> /00002
> 1
> ...
>
> Within the second jar 00002.jar, there's a folder calles "images".
> So i try to acces the images by calling.
> Image img = Toolkit.getDefaultToolkit().getImage("./images/image.png");
> I also tried:
> Image img = Toolkit.getDefaultToolkit().getImage("./00002/images/image.png");
>
> It doesn't work.
> Did anyone have success with this? I don't know what i forgot or what I am doing wrong.
>
> Cheers
> bloomfield
> [Message sent by forum member 'bloomfield' (bloomfield)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282947
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

Bill Foote

Let me clarify this, since a paragraph structure and wording
problem has been pointed out to me...

I'm not saying you should use the DSMCC API in this case.
In fact, if you have the permissions to access the disc
filesystem (or the BUDA), then the DSMCC API would just
add overhead. The cookbook's menu does use DSMCC, but I
just meant that as an example to show that even there, you
don't put assets in the classpath.

In Denny's case, not only would I not put the assets in the
classpath, I also wouldn't use the DSMCC API, and I probably
wouldn't even put them in a JAR file.

Bill

Bill Foote wrote:
>
>
> Hi Denny,
>
> An assets file doesn't need to be in the classpath. It just
> needs to be somewhere in the filesystem where you can access it
> from Java.
>
> For example, the HD cookbook's menu app mounts the filesystem
> using the "DSMCC" API from MHP. Since you're putting it in the
> BUDA, and presumably your app is signed and can read files from
> the BUDA, you don't even need to do that; you just need to load
> the image from the file directly, using the absolute pathname of
> the file (and not the relative path name).
>
> You don't even need to do the VFS update - just read it off the
> BUDA filesystem, and access it from there.
>
> By the way, you might look into putting the image files directly
> on the disc, rather than putting them inside a JAR file. If you're
> reading them straight off the optical filesystem (and not mounting
> a filesystem using the DSMCC API), I can't think of an advantage to
> putting them in a JAR. Indeed, I'd expect it would add overhead.
>
> Bill
> --
> Bill Foote bill.foote @ sun.com
> Blu-ray Java and Authoring Architect Sun Microsystems, Los Angeles

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

bloomfield
Offline
Joined: 2008-01-28

Hey Bill,

thanks for your help. The thing is, i have to download the images and don't want to put them onto the disc. Of course i could download them image by image, but i think this would make the download routine slower because i'm talking about 10-30 images in some cases. So i decided to pack them into a jar file. My thought of updating vfs and adding the images to the classpath to access them, came up because i also download some other files which i'm including in the vfs anyway (even the application which needs to access those images), so i thought it wouldn't be too much extra work.
But right now, after reading your answers i think that using DSMCC API would work fine for me too.
So, thank you for your time.

Cheers
bloomfield

billf
Offline
Joined: 2004-02-13

> But right now, after reading your answers i think
> that using DSMCC API would work fine for me too.

Hi,

Sorry for calling you "Denny." I got you confused with
Denny Britenfeld :-) What's your first name, anyway?
(Pet peeve: I wish these online bulletin board things
used real human names with capital letters and spaces -- in
a professional environment, we don't exactly call ourselves
1337h4k0rd00d anyway, and anonymous pseudonyms can have spaces,
too. But, unfortunately java.net goes off
login IDs, so when I use the web-based forum, I come out as
"billf" instead of my real, English-language name. Sigh.)

OK, I'm glad you're seeing a solution here...

I'm a bit of a fanatic for runtime efficiency and fast start-up
time... I'm assuming that the VFS update happens once, whereas
watching the disc happens multiple times? If that's the case, it
would probably be worthwhile to unpack the zip file within the
app that does the VFS update. That is, use the java.util.zip stuff
to pull the individual images out of the downloaded zip file and store
them in the BUDA, do the VFS update, and then access them
via bluray.vfs.root (assuming the xlet doing the accessing has
the right permissions).

BTW, I assume you're using an image mosaic? If there are more than
a couple of images, that's what I'd do, even if it means installing
a web service to dynamically make the mosaic server-side. Again, this
is assuming that you're optimizing for disc start-up time, but that's
usually the right thing to do for a good viewer experience.

The client side code to use a mosaic is really simple - it's basically
just com.hdcookbook.util.ManagedImage and its two subclasses, plus
a tiny bit of support code (ImageManager and AssetFinder).

Anyway, this level of optimization might not be appropriate for your
particular project, but since we're on the subject I thought it'd be good
to go into optimization a bit.

Cheers,

Bill

bloomfield
Offline
Joined: 2008-01-28

Hi Bill,

thanks again for the answer. My real name is Jan.
Unfortunately i don't succeed in loading images from the jar file.
As i already mentioned, i integrated the jar file into the vfs.
So i use the Locator String "bd://JAR:00002".
But i always get a DSMCCException when calling the method attach of the ServiceDomain object.

heres my code:

BDLocator loc;
Image [] extractedImages = new Image[5];
ServiceDomain imageJar = new ServiceDomain();

try
{
//is this correct?
loc = new BDLocator("bd://JAR:00002");
//here i get the exception
imageJar.attach(loc);
//... load images
...
catch (Exception ex)
{
ex.printStackTrace();
}

What am i doing wrong?
Can i also tell the ServiceDomain object to mount a jar file not integrated in the VFS, but stored in BUDA?

Cheers
Jan

Joe Rice

Jan,

If you want to use the DSMCC API to attach the JAR, it needs to be
listed in your BDJO's AppCacheInfo(). So when you do the VFS update,
you should also update the BDJO to one that includes the cache entry
for the JAR.

(See BD-ROM spec Part3-2, Section P.2.2.2)

Cheers,
Joe

On Jul 1, 2008, at 3:16 AM, bd-j-dev@mobileandembedded.org wrote:

> Hi Bill,
>
> thanks again for the answer. My real name is Jan.
> Unfortunately i don't succeed in loading images from the jar file.
> As i already mentioned, i integrated the jar file into the vfs.
> So i use the Locator String "bd://JAR:00002".
> But i always get a DSMCCException when calling the method attach of
> the ServiceDomain object.
>
> heres my code:
>
> BDLocator loc;
> Image [] extractedImages = new Image[5];
> ServiceDomain imageJar = new ServiceDomain();
>
> try
> {
> //is this correct?
> loc = new BDLocator("bd://JAR:00002");
> //here i get the exception
> imageJar.attach(loc);
> //... load images
> ...
> catch (Exception ex)
> {
> ex.printStackTrace();
> }
>
> What am i doing wrong?
> Can i also tell the ServiceDomain object to mount a jar file not
> integrated in the VFS, but stored in BUDA?
>
> Cheers
> Jan
> [Message sent by forum member 'bloomfield' (bloomfield)]
>
> http://forums.java.net/jive/thread.jspa?messageID=283592
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

bloomfield
Offline
Joined: 2008-01-28

Hey Joe,

thank you very much. That was the problem.
Now it works.
Cheers
Jan