Skip to main content

Java ME and remote classes

5 replies [Last post]
quo
Offline
Joined: 2008-07-13
Points: 0

I need to develop server side Java application that will be on computer, Linux or Windows, and a client for mobile CLDC device.
For future development of application, I'm trying to figure out is there a way to conduct changes only on server side.

[Example]
Application has to do two things. A and B, respectively. Client on mobile device has the code and the forms to obtain it. Later, someone add thing C to server side. That action leads to changing or adding classes on client, and I want to find solution as follows:
-client don't have classes for work A, work B, work C etc. What he does is to load classes or data from server and use that data.

I have two ideas, I don't know if they are working. I will list here my ideas:
1. create CLDL class on server and mobile device will call remote class
2. create XML data on server and mobile device will generate class according to XML data.

Does any of these ideas work (if yes how can I implement it)? Is there some other solution?

Thx in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
davjoh
Offline
Joined: 2007-07-18
Points: 0

Like everyone else who's replied has already pointed out, there is no class loading available in CLDC, so you have to find another solution really.

Well, if the updates aren't too frequent, you could always just build into your application some sort of update-notification which would link to a new build of your MIDlet to download and install OTA. So e.g. server side you update some functionality, and on your server-side you also have an auto-build of a new mobile client that can be deployed on a Web URL, which your old mobile client will be notified of the change in service and where to update the client from. Sounds a bit of a hassle, but it saves on creating too complex a mobile client.

Another alternative is to make a generic 'framework' MIDlet which is configured with your own proprietary code or XML specifications which allow whatever behaviour to be dynamically 'programmed' by a server. So a little bit like your solution (2), but what I mean is that instead of generating actual classes, the existing classes are configured to behave however you like (e.g. creating GUI components on the fly). This solution could potentially be horribly complicated, but the benefits great.

I remember an Aussie bloke talking about exactly that kind of this (was it the AirScape guy??) in one of the MECo podcasts, possibly from ME Developer Days. I can't remember the details - just a line sticks out that was something like, 'Our application can be whatever you want it to be,' which at first I thought was a bit silly until he described it in further detail. Anybody else remember that podcast (more fully than I)?

davjoh
Offline
Joined: 2007-07-18
Points: 0

Ah found the podcast I was thinking of, actually from Mobility Days in Sydney:

http://today.java.net/pub/a/today/2008/04/02/javamobility-podcast41.html

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

Quo,

Robin is correct that doing the class loading thing on ME is not possible. However if you are needing a class to hold your data, then you might try a hashtable. This would allow you to put anything into it given a key name. Then to do something like text substitution you could ask the hashtable for that variable, and load in the results. You would want to most likely have a string key, and an Object values where the values class would have a few things like type of variable, and the value, the name might be good, and possibly a length for strings to speed up some of your code. Maybe have 2 types of classes for the value, one for primitives, and the other for strings, and possibly a third for objects which had something like class name, etc..

There is another couple of solutions too, there is a product called MoJax my mFoundry that allows for dynamic code updates, it does this by providing a javascript engine in ME.
There is also another product called Bling, from Blingsoftware which is similar, but give you more control over the server, and business end of the system. Again another JavaScript solution.
Then there is Widsets by Nokia, that is more of a Java based language. Or like I did for a company write your own VM in javaME. Yes it can be done, no it is not simple. :)

Good luck,
-Shawn

Thomas Landspurg

And there is also Webwag, from Webwag, which provides also a mobile widget
engine running fueld by a tinyJavaScript engine...
http://api.webwag.com and http://www.webwag.com/mobile

This can also be used to do what you describe...

On Mon, Jul 14, 2008 at 5:52 PM, wrote:

> Quo,
>
> Robin is correct that doing the class loading thing on ME is not possible.
> However if you are needing a class to hold your data, then you might try a
> hashtable. This would allow you to put anything into it given a key name.
> Then to do something like text substitution you could ask the hashtable for
> that variable, and load in the results. You would want to most likely have
> a string key, and an Object values where the values class would have a few
> things like type of variable, and the value, the name might be good, and
> possibly a length for strings to speed up some of your code. Maybe have 2
> types of classes for the value, one for primitives, and the other for
> strings, and possibly a third for objects which had something like class
> name, etc..
>
> There is another couple of solutions too, there is a product called MoJax
> my mFoundry that allows for dynamic code updates, it does this by providing
> a javascript engine in ME.
> There is also another product called Bling, from Blingsoftware which is
> similar, but give you more control over the server, and business end of the
> system. Again another JavaScript solution.
> Then there is Widsets by Nokia, that is more of a Java based language.
> Or like I did for a company write your own VM in javaME. Yes it can be
> done, no it is not simple. :)
>
> Good luck,
> -Shawn
> [Message sent by forum member 'sfitzjava' (sfitzjava)]
>
> http://forums.java.net/jive/thread.jspa?messageID=286453
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

--
Thomas Landspurg
http://blog.landspurg.net

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Robin Chaddock

CLDC does not provide java.lang.ClassLoader, and so provides no mechanism
for runtime definition of Java classes.
CLDC also does not support java.rmi.

Therefore, implementing what you describe in the way you describe it is
impossible.

Obviously there are other ways of achieving this functionality (running
arbitrary code on a thin client) but you'll no doubt find them restrictive,
cludgy and inefficient.
A better solution would be to target CDC rather than CLDC., where all of the
api functionality you require is exposed. (with the rmi package itself being
an optional addition)

----- Original Message -----
From:
To:
Sent: Sunday, July 13, 2008 7:58 PM
Subject: Java ME and remote classes

>I need to develop server side Java application that will be on computer,
>Linux or Windows, and a client for mobile CLDC device.
> For future development of application, I'm trying to figure out is there a
> way to conduct changes only on server side.
>
> [Example]
> Application has to do two things. A and B, respectively. Client on mobile
> device has the code and the forms to obtain it. Later, someone add thing C
> to server side. That action leads to changing or adding classes on client,
> and I want to find solution as follows:
> -client don't have classes for work A, work B, work C etc. What he does is
> to load classes or data from server and use that data.
>
> I have two ideas, I don't know if they are working. I will list here my
> ideas:
> 1. create CLDL class on server and mobile device will call remote class
> 2. create XML data on server and mobile device will generate class
> according to XML data.
>
> Does any of these ideas work (if yes how can I implement it)? Is there
> some other solution?
>
> Thx in advance
> [Message sent by forum member 'quo' (quo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=286280
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".