Skip to main content

HelloWorld (MainXlet) in BDMV tree by itself?

10 replies [Last post]
sfritzinger
Offline
Joined: 2008-02-05
Points: 0

Hey all!

I'm jumping into BD-J development head first. I bought the book (HD Cookbook), have visited the site (hdcookbook.com), and seen the helloworld tutorial (http://wiki.java.net/bin/view/Mobileandembedded/Blu-RayDiscHelloWorld)

I just can't seem to get PowerDVD to play back the MainXLet and display the helloworld message. :-P The sample tree using GRIN and GunBunny runs correctly in PowerDVD.

All files were downloaded from the hdcookbook site and are unmodified.

Here is what i've done:
1) Compile MainXlet.java using the BD-J class zip (yields MainXlet.class, no errors, works correctly in XletView)
2) Create 00000.jar via: jar -cvf 00000.jar MainXlet.class
3) Create 00000.bdjo via: java -jar lib\bdjo.jar 00000.xml
4) Create the following directory structure:
BDMV
---- index.bdmv
---- BDJO
-------- 00000.bdjo
---- JAR
-------- 00000.jar

The 'index.bdmv' file was copied from the sample bdmv tree from hdcookbook.com. I assume that points to 00000.bdjo which then points to my 00000.jar file.

I then run PowerDVD 8 (that came with my sony blu-ray writer), loading the top-level directory. In vista, the screen switches a bit and I get the 'Play' message and then about 2 seconds later it switched back and PowerDVD goes back to the initial screen (with the default startup background).

At no time do I see the "Hello World..." message on the screen.

My questions would be:
1) In the 00000.xml, there are playlists referenced. Should these be removed since there are no playlists in my test directory? From my reading, playlists are not necessary since I have no assets; just a simple xlet.

2) Should the MainXlet example work properly in this way? Do I need a main thread loop to continually run and show the message? I'm wondering if it is drawing it to the screen properly, but since there is no main loop, it exits immediately and therefore I can't see the text. That doesn't seem correct though from my reading.

3) Are other directories/files required for it to run properly? I tried dropping the JAR file in the sample tree and overwrote 00002.jar with the helloworld jar and PowerDVD loaded the sample tree and just sat at a black screen until I shut it down a minute later. I assume this is because the helloworld jar just exitted and the supervisor jar just sat there doing nothing.

Thank you in advance for answering these questions. I'm REALLY excited about getting this far and feel I am close. I can't wait to really dig in. I'm experienced in Java programming and have toyed with JavaTV, but with Blu-Ray essentially putting JavaTV in the living room, there is a LOT of potential!

-Scott

Message was edited by: sfritzinger

Message was edited by: sfritzinger

Message was edited by: sfritzinger

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Congratulations, Scott! I can certainly relate to your frustration and joy here.

And thanks for the detailed instruction, I wouldn't have been able to come up with this myself.

Chihiro

sfritzinger
Offline
Joined: 2008-02-05
Points: 0

Chihiro,

First, thank you for your reply. It is greatly appreciated.

I decided to backtrack a bit an do what you suggested. I copied the blu-ray disc image from the book's CD to my hard drive. I tested it after copying and it worked fine in PowerDVD.

From there, I copied the main_bdjo.xml file and generated a 00000.bdjo file from it unmodified (to make sure that I was generating the bdjo file correctly). I copied the 00000.bdjo file to the BDJO disc image directory and tested. It ran fine. So, I know that I have a functional BDJOGenerator.

After that, I editted the main_bdjo.xml file to put the MainXlet JAR file as the second base directory. Here is the applicable part of the xml file:



00002
TITLE_BOUND_DISC_BOUND

0

MainXlet

128 1
0
0

1
1
0
0

2
V_01

0x4002
1
0x56789abc
1

I then regenerated the BDJO file, copied it to the disc image directory and tested. Now what happens is I get the "Play" icon in PowerDVD and it sits there with a black screen.

Something just seems to be missing on my end. This test showed that, with a minimally invasive change, I still can't get it loaded :-P

Any further suggestions would be helpful. Thank you!

-Scott

chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Hi Scott,

00002

This would mean that your jar must be named as 00002.jar. Other than that, I don't see anything obvious.

Are you getting trace logs from PowerDVD? If so, you can add some System.out.println in the xlet to see whether the xlet is being launched and started, perhaps in initXlet and startXlet section.

Also, PowerDVD had some font issues, at least in the earlier versions that I started with, when video is not playing in the background. I was so frustrated by not seeing anything on the screen for the longest time, and then realized that once I change drawString calls to drawRect or other primitive drawings calls, then things start showing up. This might be the thing to try if you're getting your methods invoked but still not seeing the string painted.

Best,
Chihiro

sfritzinger
Offline
Joined: 2008-02-05
Points: 0

Chihiro,

Thank you again for the reply.

I did originally name the MainXlet jar "00002.jar" and overwrite the existing one in the book's disc image.

I tried drawing a red rectangle background but nothing shows up. :-(

I've also tried adding some System.out.println calls but nothing appears to happen. I saw the page on how to get debug output out of PowerDVD (using BDJDebugLog in PowerDVD's reg key) but no log files (javaLog.txt or DVBTestLog.txt) are generated. I am using PowerDVD 7.3. I have version 6.6 here as well (which came with my blu-ray writer). I'm wondering if I should install that to see if the debug hooks are in that one.

Any other ideas or suggestions would be greatly appreciated.

Thank you.

-Scott

sfritzinger
Offline
Joined: 2008-02-05
Points: 0

PROGRESS!

Well, sort of :-) Hopefully this is the straw...

After trying PowerDVD 6.6 (which doesn't want to load BD-J images apparently) and reverting back to 7.3, I went to get coffee to decompress. Realizing I was running Vista and that the Program Files directory is not global write, I drove home quickly and decided to run PowerDVD "as Administrator" (my account is admin, but still requires permission to write to Program Files) and... low and behold... the javaLog.txt file shows up. YAY! I can't believe I didn't try that earlier. You'd think 'years of development experience', but ... oh well.

Now I can see why it isn't being loaded:
-----------------------------------------------------------------------
[BDJPrimitiveCommand.doLoadXlet()] [ERROR!]caught exception when it's loading the xlet
java.lang.NoClassDefFoundError: MainXlet$1
at java.lang.Class.getConstructor0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.cl.bdj.appmanager.BDJAppUtil.createXletInstance(Unknown Source)
at com.cl.bdj.appmanager.BDJPrimitiveCommand.doLoadXlet(Unknown Source)
at com.cl.bdj.appmanager.StartXletCommand.execute(Unknown Source)
at com.cl.bdj.event.BDJCommandRunner.run(Unknown Source)
at java.lang.Thread.run(Compiled Method)(Unknown Source)
at java.lang.Thread.startup(Unknown Source)
[BDJPrimitiveCommand.doLoadXlet()] load BD-J app ended : MainXlet
-----------------------------------------------------------------
It is dying during loading/instantiation. AHHHHHH.

Now my question is, what is going on here? I have the HelloWorld (MainXlet) unmodified from the hdcookbook site. For some reason, it can't find the constructor?

I feel like I'm so close. When this works, I'll probably see how stupid a mistake I made :-P

Anyone have any ideas? Thanks!

-Scott

bddeveloper
Offline
Joined: 2008-01-14
Points: 0

Hello,

Does your MainXlet use/or is an innerclass? Also what package is your MainXlet class in?

Scott

sfritzinger
Offline
Joined: 2008-02-05
Points: 0

I just came back to the forum to report SUCCESS.

In the interest of helping others in the same position, and at risk of looking like a total newbie (which, in BD-J, i totally am), I was including MainXlet.class in the JAR file, but not MainXlet$1.class (which is required?). After including MainXlet$1.class, The "Hello BD-J World..." message showed and everything ran great!

Here is what I did (to let others know):
- Compile MainXlet.java against the BD-J reference classes (or against javatv.jar and openmhp classes)
- Create a JAR that includes MainXlet.class and MainXlet$1.class
- Copy main_bdjo.xml from the "HD Cookbook" CD and modify base directory 00002's initialClassName to "MainXlet"
- Create 00000.bdjo from main_bdjo.xml using BDJOGenerator and copy it to the disc's "sample disc" BDJO directory (overwrite existing)
- Copy my MainXlet JAR file over 00002.jar in the JAR directory (overwrite existing)

Seems so simple now... but ... wow that was an exercise in frustration on my end. I don't have much hair left to pull out :-)

Thanks for the help so far Chihiro and bddeveloper! I'm sure I'll have further questions but at least i'm bootstrapped now.

-Scott

bddeveloper
Offline
Joined: 2008-01-14
Points: 0

Just as an old schooler in Java, the rule of thumb in the past was to avoid using inner classes when you had a class that would get created several times, an example is Say a person object that has an innerclass of Address and the Person object would be created a lot (per person), the creation of the Person object is slower because of its innerclass at least in the old days this was true.

Obviously your Xlet is instantiated just once so its a non issue, but just as a future reference if the VM uses the same logic as the past VM's then innerclasses can have an effect on your performance. However I do not know so I can't say for sure.

Bill Foote

In terms of runtime overhead, an inner class is identical
to a normal class. It's really just a syntactic convenience. The
overhead that you mostly care about as an xlet author is the class
loading time - it's a good idea to try to not have too many classes
in your xlet, because loading those classes takes some time. Once
the class is loaded, it takes almost no time to instantiate it.

I wouldn't recommend going too an extreme, like putting all of your xlet
code in one class - you should still
write well-structured modular code, and breaking things up into classes
is an important tool. "Moderation in all things".

In case folks aren't familiar with inner classes, here's an example:

public class MyClass {

public void foo() {
Runnable r = new Runnable() {
public void run() {
System.out.println("hello");
}
};
Thread t = new Thread(r);
t.start();
}

}

The variable r gets an instance of an anonymous class that implements
the Runnable interface. Most compilers will call this anonymous class
MyClass$1, and it will be emitted as MyClass$1.class. Except for the
name of the anonymous class, the above code is exactly equivalent to:

public class MyClass {
public void foo() {
Runnable r = new MyRunnable();
Thread t = new Thread(r);
t.start();
}
}

public class MyRunnable implements Runnable {
public void run() {
System.out.println("hello");
}
}

The performance of the two styles is the same.

Cheers,

Bill

bd-j-dev@mobileandembedded.org wrote:
> Just as an old schooler in Java, the rule of thumb in the past was to avoid using inner classes when you had a class that would get created several times, an example is Say a person object that has an innerclass of Address and the Person object would be created a lot (per person), the creation of the Person object is slower because of its innerclass at least in the old days this was true.
>
> Obviously your Xlet is instantiated just once so its a non issue, but just as a future reference if the VM uses the same logic as the past VM's then innerclasses can have an effect on your performance. However I do not know so I can't say for sure.
> [Message sent by forum member 'bddeveloper' (bddeveloper)]
>
> http://forums.java.net/jive/thread.jspa?messageID=258114
>
> ---------------------------------------------------------------------
> 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

chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

I believe you do need directories for playlist, streams etc under BDMV even if you have no assets in there, plus the CERTIFICATE dir even if your xlet will be unsigned. For a quick xlet testing, I'm starting off of a disc structure that looks like this, below, and insert my jar and bdjo files.

Meanwhile, taking the BDMV image at our documents & files section, 2007_10_hdcookbook_disc_image_no_jar_bdjo.zip and swapping 0002.jar of our hdcookbook xlets build with your code should be OK, as long as you're also updating the bdjo file from the hdcookbook one to your helloworld one. You shouldn't have to worry about the animation loop for that helloworld example. The string is drawn onto the Java graphics plane and just stays there...

$ find -name *svn -prune -o -print
.
./BDMV
./BDMV/AUXDATA
./BDMV/AUXDATA/00000.otf
./BDMV/AUXDATA/00001.otf
./BDMV/AUXDATA/dvb.fontindex
./BDMV/BACKUP
./BDMV/BACKUP/AUXDATA
./BDMV/BACKUP/AUXDATA/00000.otf
./BDMV/BACKUP/AUXDATA/00001.otf
./BDMV/BACKUP/AUXDATA/dvb.fontindex
./BDMV/BACKUP/BDJO
./BDMV/BACKUP/CLIPINF
./BDMV/BACKUP/index.bdmv
./BDMV/BACKUP/JAR
./BDMV/BACKUP/META
./BDMV/BACKUP/META/DL
./BDMV/BACKUP/META/ES
./BDMV/BACKUP/META/TN
./BDMV/BACKUP/MovieObject.bdmv
./BDMV/BACKUP/PLAYLIST
./BDMV/BACKUP/STREAM
./BDMV/BDJO
./BDMV/CLIPINF
./BDMV/index.bdmv
./BDMV/JAR
./BDMV/META
./BDMV/META/DL
./BDMV/META/ES
./BDMV/META/TN
./BDMV/MovieObject.bdmv
./BDMV/PLAYLIST
./BDMV/STREAM
./CERTIFICATE
./CERTIFICATE/BACKUP
./CERTIFICATE/BACKUP/id.bdmv
./CERTIFICATE/id.bdmv

Best,
Chihiro