J2ME development and native API - java-me

Is it possible to write a mobile application with J2ME and whenever we want to implement a functionality not offered by J2ME call native mobile API ? (kind of like what is done with .NET, whenever you need something not provided, you just call the Win32 API from the .NET platform).

While JNI is not officially supported in J2ME, the Symbian implementation of J2ME obviously uses something very similar.
Since most J2ME APIs have a corresponding Symbian OS C++ API, what Symbian did (a lot) is develop adaptation layers between the 2.
Between that and the new modular architecture of the IBM J9 virtual machine (from Series60 3rd edition feature pack 2 onward), it is technically possible to add a new API to the virtual machine without actually needing to recompile most of a handset firmware.
However, third party developers simply are not allowed to do it without a lot of help from the handset manufacturer.
A loopback socket connection is the solution that people have tipically implemented to transfer data accross the language barrier. Large-scale deployment is not the easiest task, though, as you technically need to install 2 applications on the device. Once you understand the threading model of the Symbian J2ME implementation, you also realize how ugly and inefficient a hack it is.
When you reach that kind of issue, it's time to learn Symbian OS C++ and do it right.

No. That's not possible with Java ME.

Only sort of. Actually it is possible but not directly. You can write a native server that listens on a local socket and send requests to it from your Java MIDlet. Someone even released a framework to do this called MIDP-JNI (as opposed to real JNI). Obviously the form of the solution imposes some limitations on what you can do with it but it isn't actually impossible.
Be aware that using this approach can make your application much more complex to debug.

If you are specifically looking out for Nokia/Symbian, then APIBridge http://wiki.forum.nokia.com/index.php/J2ME_API_Bridge_Interface could be a solution. Typically it is the 'official' version of 'native server on local socket' kind of thing. The APIBridge is 'extensible' & you can write your own 'plugins' for your suitable 'low-level' task.

Related

Best way to include Socket MvvmCross with PCL

First I would like to thank you (Stuart in special) for this amazing framework MvvmCross.
I have an application case that involves socket connectivity, and I would like to go with PCL for Android, WP7 and iOs.
Unfortunately, the PCL subset doesn't support sockets usage as is (I think NCL is supported only for Microsoft different frameworks).
I thought may be MvvmCross Plugin is the way to go, but still needs plugin implementation for each platform (I mean ...plugin.Droid, ..plugin.WP7 etc..) while it should be the same code at the end.
What do yo suggest?
Thanks
I thought may be MvvmCross Plugin is the way to go
Yes, this is exactly the sort of situation that Plugins were designed for.
I'd certainly implement this as a socket plugin:
The PCL part of the plugin would provided a socket interface, although it might also perhaps include some shared base class 'buffer copy' type functionality in the shared code too.
The platform specific socket implementations which handle raw socket connection and IO.
It's likely that these platform plugin additions would use quite a lot of file linking between several of the platform implementations - I'd expect there to be a lot of code that would have to be shared this way.
I think a sockets plugin will be quite a common requirement - so if you were to tackle this via open source, then you might find some willing contributors ... or, if you were to go closed source, then you might find some customers.
While no-one has open-sourced an IP network socket implementation at this stage, the Sphero project did include a Bluetooth socket example - albeit one that wasn't entirely network efficient in the way it communicated.
This Bluetooth socket code is open sourced within Ms-PL at https://github.com/slodge/BallControl/tree/master/Cirrious.Sphero.WorkBench/Plugins/Sphero
This Sphero plugin doesn't expose a PCL Sphero-Socket level API - instead at the plugin level it chooses to expose a Sphero-Robot level API.
With the benefit of hindsight (a wonderful thing), if I implemented this again then I'd implement:
a bluetooth serial port plugin exposing bluetooth scanning, connecting and socket streaming
an additional PCL library which consumed the plugin to drive the robot - this perhaps might be called a plugin but would not have any non-PCL code within it.

What platform(s) to use for developing an audio mixing web app?

I am working on a browser-based application that is essentially a Digital Audio Workstation. I've seen one out there (at http://www.indabamusic.com), and it looks like it is a Java applet. Is a Java applet the best way to do this?
I've read that C++ is generally more widely used for audio programs, and I've looked at Wt ( http://www.webtoolkit.eu/wt/) for a web interface option but it doesn't seem to be meant for this kind of use (correct me if I'm wrong).
I have almost no experience with C++, so I might just be biased.
You either want a java applet or to do it in Flash (perhaps Flex). It is generally messy to get C++ bits deployed broadly in a browser.

can npapi do everything that ActiveX can?

I wanted to write a B/S project that client side uses ActiveX or Gecko to Communication with server via network socket. And any browser(ie/firefox/chrome/opera/safari) can use it.
If you want to support every major browser than you need to write both the ActiveX part (for IE) and the NPAPI part (for all other browsers). You can use support both technologies with one DLL though.
An easier way than implementing both yourself would be to use FireBreath, which does that for you and provides an abstraction layer over those APIs.
As you write native code with both technologies, sockets etc. can be used with both. The biggest limitations are with the UI side and permissions due to running code in a host application.
Note that XPCOM as a plugin technology is obsolete.

Can I compile Dalvik for WinCE? How?

mY general question above and simple - can I compile Dalvik VM for WinCE? In particular, I want to run some android-compatible projects under WinCE 5.0. Obviously, it's sounds afraid, but interesting for me:)
I don't think it would help you. In fact, since the code is just Java, you could compile it for regular JVM and there are some for WinCE. The problem is you'd need the user interface and system libraries and porting those would be huge amount of work.
If you are writing the application, the best I can suggest is that you use some kind of portability layer. There are e.g. J2ME polish, LWUIT (Android port) and certainly more. With those you will be able to run on most mobile devices that have Java.

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone?
The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service writen in pascal.
The 'not so' big picture: I´m trying to write a php to emulate a SOAP Midas packets to ClientDataSets in delphi, but i dont have the necessary muscules in my brain to do that. So i could try to convert dbexpress to FPC, but i don´t know if this is legal.
Ok folks, i know that PHP, java, c#/asp, python, ORM´s and things like that could help me with this, but i´m a GUI guy! Everyone who ever programmed 10000 lines report in cobol knows what i´m talking about. I just want to point my soap connection to some server in the net (i dont own the service providers) and make my customers happy. Simple as...
RemObjects SDK supports Free Pascal. And Free Pascal is a Delphi compatible Pascal compiler for, amongst others, Linux platforms.
http://wiki.remobjects.com/wiki/Introduction_to_Free_Pascal_support
If you are familiar with FPC and don't like to write many lines of code (as you pointed out), I think RemObjects SDK is really an interesting option.
A Delphi cross-platform edition is in the works. Hopefully with the next version of Delphi it is possible to build DataSnap servers for the Linux platform.
You can do this with Lazarus and the wst (web service toolkit). We use it for some client / server projects. In Lazarus you can use (almost) 100% compatible Delphi code and you can compile to native apps for Windows, Linux and OSX.
Only problem is the learning curve , which is rather seep.
The Delphi 2010 DataSnap support REST protocol and JSON as data packet. Perhaps this may helps if you want to design your solution to integrate your Delphi apps with non Delphi apps.

Resources