Skip to main content

Using JAR files with your Xlet

8 replies [Last post]
jeng_sci
Offline
Joined: 2008-11-11
Points: 0

I have created some helpful utility classes and JARed them up so that I dont have to copy and paste the same code into my other projects.

I can compile my Xlet, which references some of the classes in the JAR file. But when I try to run the Xlet in a simulator, I get a "NoClassDefFoundError". I have added the JAR file to the classpath and added it to my project.

Is there some security reason why OCAP would prevent an Xlet from trying to use classes in an external JAR file?

Eventually, I would like to release my JAR file for other developers to use, which is what sparked this thread. I am using Vidiom workbench for my development.

-jeng_sci

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
billf
Offline
Joined: 2004-02-13
Points: 0

Putting something in the classpath of the simulator seems dubious -- and not something you could do on a real OCAP box anyway. Is that what you're doing, or do you mean that you add the JAR to an application class path of the simulator that's intended for this purpose?

Why not just have your build system combine the library classes and the application classes into one JAR file? That seems the simplest. When you get to real deployment, then I think the AIT lets you have an application class path that spans multiple JAR files, which might lead to some bandwidth conservation or something if a given library is used more than once, but during app development I'd, personally, just be simple and conservative, and stick the entire application in one JAR file (unless, of course, the simulator has an easy way to specify an application class path, as distinct from the classpath that the simulator runs under).

Anyway, making one big jar would be a good start, in that it lets you rule out several potential points of failure.

Bill

jeng_sci
Offline
Joined: 2008-11-11
Points: 0

Thanks for the reply. I have read up of how to use JAR files the documents suggest I add them to my CLASS_PATH or add them to the project directly. But you make a good point that this will not work on a real STB.

The reasons why I didn't want to include my classes into my other test xlets:
1) I want to eventually distribute my JAR file to 3rd party OCAP developers to enhance their applications.
2) I dont want the proprietary source code reveiled to my company's competitors.

Currently, I have put everything in one test project for my tests.

Regards,
jeng_sci

billf
Offline
Joined: 2004-02-13
Points: 0

You can distribute JARs to 3rd party OCAP developers, and you don't need to reveal source code... At worst, someone who uses your library would just un-jar your JAR file (thus obtaining the individual .class files), then combine that with the .class files of their app into one big JAR file. No source need be involved.

Bill

jeng_sci
Offline
Joined: 2008-11-11
Points: 0

Thanks. I misunderstood your previous post about combining just the class files into one big jar file.

I am currently examining the OCAP v1.0 and v1.0.1 spec about "shared classes" and the "class loader" to get a better idea of how it works.

jeng_sci

markminnoye
Offline
Joined: 2008-05-29
Points: 0

Hi Jeng,

When loading your application over the return channel you *can* define multiple zip files. (see "Transport via interaction channel" transport protocol descriptor") in MHP 1.0.3 specs.

Some middleware vendors could support having jar-files in the classpath definition ("DVB-J application location descriptor").

Worst case scenario you can create your own classloader to load classes from jar files.

Cheers,
Mark

vovikg
Offline
Joined: 2009-06-19
Points: 0

> ....
> Worst case scenario you can create your own
> classloader to load classes from jar files.
>

Is this even allowed? I thought the best you could do is to use a pre-defined DVBClassLoader, granted you can base one on a URL pointing to a jar file, whether it will be able to find classes in the archive will likely depend on the version of stack you're running on.

krishnaveni17
Offline
Joined: 2008-09-24
Points: 0

Hi ,

OCAP 1.0 specification does not support external jars. As you can see, you can still compile against an external jar; however, the stack does not have a ClassLoader implementation that allows classes to be loaded.

Whereas the OCAP 1.0.1 specification does introduce external jars loading.
I think , Vision Work Bench is supporting OCAP 1.0 specification. so we cannot load external jars.
So the best option is to place the source files in the application to make them available. I hope this works for you. :)

Out of Curiosity, may i know the services that you developed in the library jar file?

Thanks,
krishna.

jeng_sci
Offline
Joined: 2008-11-11
Points: 0

Thanks for the reply. I am currently scouring the OCAP spec 1.0 for the place where they discuss the limitation of using external JARs so that I can show my manager the wall I just crashed up against.

As far as the library I am developing, all I can say is that it deals with RTSP communication.

Thanks again,
jeng_sci