views:

801

answers:

5

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).

+2  A: 

No. That's not possible with Java ME.

Pablo Santa Cruz
Java uses JNI to call native code, but this isn't supported in J2ME.
kgiannakakis
thanks.so that means whenever a functionality is not provided in J2ME, i'm basically doomed.
Attilah
Unfortunately, pretty much, yes. Java ME these days provides a lot though. Including access to phone's camera, i.e.
Pablo Santa Cruz
however writing native code is not possible considering the security aspects
Ram
+1  A: 

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.

Mark Wilcox
+2  A: 

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.

QuickRecipesOnSymbianOS
A: 

I would like to listen the slide IN/OUT event of the NOKIA devices(Touch + QWERTY Keyboard) in J2ME App. I need your inputs for the same. Do i need to follow complex implementation or is there any other way around?

rajiv
+1  A: 

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.

Pocha