Question

I am writing a blackberry application - after the application has started I need to get a .class file(or maybe something else like a .COD file?) from a database(I will probably have to create a web page from which to get the file) and then instantiate it and invoke its methods... Can anybody help me? Please?!?

The point is to allow students to get code on their phones and see what a method would return. A teacher would write a simple programming method that returns some integers. The students need to be able to get that method into the application. They can see the code and enter what they would expect the method to return. Then they need to be able to run the method so as to be able to see what the method returns...

Basically I want to be able to unit test some code that isn't on my blackberry yet...

I saw an advert for an app which does something similar... How can I do this: .net for BlackBerry (C and VB.NET) If you are learning ASP.NET, C# or Visual Basic.NET, then this application allows you type .NET code onto your BlackBerry®, and view the output in seconds. It is an excellent way to try out snippets of .NET code without having to fire up Visual Studio on your PC.

Code written with this application is stored on a remote server, and thus can be recalled from other devices, so it can be shared with other users of this app.

Was it helpful?

Solution

The BlackBerry JVM doen't support reflection, however if the applications all extend a Class that is also defined in the base application, and you can derive the fully qualified name of that Class in the downloaded software you can do something similar:

abstract public class MyDemoObject {
    abstract public void myDemoMethod();
}

Then:

Class class = Class.forName("org.some.sample.ClassName");
MyDemoObject obj = (MyDemoObject)class.newInstance();
obj.myDemoMethod();

In the downloaded app:

package org.some.sample

public class ClassName extends MyDemoObject {
    public void myDemoMethod() {
        System.out.println("package org.some.sample.myDemoMethod()");
    }
}

Kind of clunky but it does work. myDemoMethod will be running in the context of the base application, which is not a bad lesson to learn about programming for BlackBerry OS.

OTHER TIPS

I think you need to put your application binaries on a server to make your students able to download them OTA. (http://blackberrystorm.wikidot.com/setup-blackberry-ota-applications)

then, you can use Global Events to communicate between your app and other apps. (http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/What_Is_-_Global_Events_and_Global_Event_Listeners.html?nodeid=800527&vernum=0)

but accessing methods from other app, on the device in real time.., I don't think this is possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top